added answers

This commit is contained in:
Jared Ramon Elizan 2022-08-14 12:06:59 +08:00
parent a3d8e50f22
commit b9ca198809
1 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,21 @@
const fibonacci = function() {
const fibonacci = function(num) {
let stringToNumber = +num;
let val1 = 0;
let val2 = 1;
let result = stringToNumber;
if( result > 0 ){
for(let i = 2; i <= num; i++){
result = val1 + val2;
val1 = val2;
val2= result;
}
return result;
} else{
return "OOPS";
}
};
// Do not edit below this line