The function take a number and checks if it is in the Fibonnacci Sequence. If it is return "yes", else return "no".
Fibonnacci sequence explained:
starts with 0 and 1. It adds the two previous numbers to get the next one, then continues the pattern.
Some of the beginning sequence: 0,1,1,2,3,5,8,13,21...
function isSquare(x) {
// code goes here
let sq = parseInt(Math.sqrt(x));
return check = (sq * sq == x)
}
function FibonacciChecker(num){
return (isSquare(5 * num * num + 4) || isSquare(5 * num * num -4)) ? "yes" : "no";
}
// Since Node 10, we're using Mocha.
// You can use `chai` for assertions.
const chai = require("chai");
const assert = chai.assert;
// Uncomment the following line to disable truncating failure messages for deep equals, do:
// chai.config.truncateThreshold = 0;
// Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
// Uncomment the following to use the old assertions:
// const Test = require("@codewars/test-compat");
describe("Solution", function() {
it("should test for something", function() {
assert(FibonacciChecker(5), "yes");
assert(FibonacciChecker(6), "no");
});
});