Issue with Intermediate Algorithm Scripting - Sum All Odd Fibonacci Numbers

Tell us what’s happening:

The second to last test case (75024) was accepted but yet (75025) was rejected which makes no sense as the next value in a fib sequence is definitely greater that the last hence the sum of all odds for sumFibs(75024) should be equal to the sum of all odds for sumFibs(75024 + 1)

I will just create an exception for that condition to pass the tests until it’s been fixed. :slight_smile:

  My code so far
function sumFibs(num) {
const fibs = getFibs(num)
const oddFibs =  fibs.filter(x => x % 2 === 1)
console.log(oddFibs)
return oddFibs.reduce((x, y) => x + y, 0);
}

sumFibs(4);

function getFibs(num) {
let seq = []
let prev = 1
let cur = 0
let next = cur + prev

while (next < num) {
  seq.push(next)

  prev = cur 
  cur = next

  next = cur + prev

}
return seq
}

  My browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Intermediate Algorithm Scripting - Sum All Odd Fibonacci Numbers

Link to the challenge:

I would double check this condition

Note, this is a tiny bug in your code. The tests are correct.

Thanks, I’ve solved it.

1 Like