1function isFibonacci(n) {
2 var fib,
3 a = (5 * Math.pow(n, 2) + 4),
4 b = (5 * Math.pow(n, 2) - 4)
5
6 var result = Math.sqrt(a) % 1 == 0,
7 res = Math.sqrt(b) % 1 == 0;
8
9 //fixed this line
10 if (result || res == true) // checks the given input is fibonacci series
11 {
12 fib = Math.round(n * 1.618); // finds the next fibonacci series of given input
13 console.log("The next Fibonacci number is " + fib);
14
15 } else {
16 console.log(`The given number ${n} is not a fibonacci number`);
17 }
18}
19
20$('#fib').on("keyup change", function() {
21 isFibonacci(+this.value)
22})