can you guys explain to me what’s happening on that line of code
a = [b, b=b+a][0];
because i’m still new to javascript . and thats why i couldn’t understand what that line of code is doing ??
Your code so far
function sumFibs(num) {
var a = 1;
var b = 1;
var s = 0;
while (a <= num) {
if (a % 2 !== 0) {
s += a;
}
a = [b, b=b+a][0];
}
return s;
}
console.log(sumFibs(4));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Sum All Odd Fibonacci Numbers
Link to the challenge: