0
Create a function that will be return of the sum of even numbers from 4 o 401. Help.
Attempt: function sum_even() { var sum = 0; for ( var i = 4; i < 387; i++) { if (i % 2==0) { sum +=i; } } return sum; }
8 Answers
+ 1
Your i is sometimes lower, sometimes upper. Otherwise looks like it should work actually. đ€
What exactly goes wrong?
+ 1
Do you call it?
+ 1
A function is a sub-code that only runs if you call it.
Write this under your function:
console.log(sum_even());
(First tidy up the syntax though. For also can't start with capital.)
0
It's not 387..its 401
0
When I run it am getting blank on my console.
0
What do you mean by call?
0
just after the function
0
Yeah.