• + 0 comments

    JavaScript:

    function isFibo(n) {
        // Write your code here
        let fibonacciSequence = [0,1];
        
        let lastFibonacci = 1;
        while(lastFibonacci <= n){
            if(lastFibonacci === n) return "IsFibo";
            
            fibonacciSequence.push(lastFibonacci);
            lastFibonacci = fibonacciSequence.at(-2) + fibonacciSequence.at(-1);
        }
        
        return "IsNotFibo";
    }