Tell us what’s happening:
I have written a code which when I used repl to run the tests it pass but here it does not pass the test number 4, 5, and 6.
what could be wrong?
Your code so far
Array.prototype.last = function(){
return this[this.length-1];
}
Array.prototype.lastBut1 = function(){
return this[this.length-2]
}
var arr = [1,1];
function sumFibs(num) {
while(arr.last()+ arr.lastBut1()<=num){
arr.push(arr.last()+arr.lastBut1());
}
var arr1=arr.filter(arr=>arr%2!==0);
var accumulator = (accumulator,currentValue)=>accumulator+currentValue;
var sum = arr1.reduce(accumulator)
return sum;
}
sumFibs(4);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers