Hi everyone! After studying with Codecademy for almost a year I’ve decided to take the leap and enter a Bootcamp. I have been doing really well, but now it’s time for me to come up with my own functions to solve the prompts. The problem is I have been working on it for about 40 minutes and every time I try to run the for loop everything crashes. I’m probably missing something simple, but the more frustrated I become, the less I can see anything wrong with the code . I will leave the prompt and my answer below. I appreciate any help! Thanks in advance.
Write a function that would get the sum of all the even numbers from 1 to 1000. You may use a modulus operator for this exercise.
var sum = 0;
for ( var i = 0; i <= 1000; i + 2)
var sum = i
} return sum;
also here is another way that I’ve tried: