freeCodeCamp Challenge Guide: Sum All Odd Fibonacci Numbers
I tried doing the exercise with .reduce to get the sum until it was <= num
but it didn’t work. I have noticed in the different answers that they first get the array with the odd numbers that meet the condition and then add it.
What I was trying to do is apply .reduce
to an array with odd numbers <= num (perhaps it was not the focus of the exercise) but it raised me the doubt that if .reduce can be stopped when meeting a condition.
Thank you, sorry for my English and I am a beginner.