I\'m trying to create a function to calculate the sum of only even numbers in Fibonacci sequence. How can I make this if/while loop to work?.
function fib() {
Replace while(x % 2) with while(x % 2 === 0). You're checking if x % 2 is true in your original while loop.
while(x % 2)
while(x % 2 === 0)
x % 2