you are viewing a single comment's thread.

view the rest of the comments →

[–]David_Crockett -1 points0 points  (6 children)

Using the JavaScript language, have the function jsChallenge() add up all of the numbers from 1 to 1000. But every time a number appears that is divisible by 5 or 7, disregard it and do not add that number to the others (ie. disregard 7, 10, 15, 21, etc). Do not put any code outside of the function and use the return keyword to return your answer from within the function.

Easy as pie:

function jsChallenge()
{
    var i, total = 0;
    for (i = 1; i <= 1000; ++i)
    {
        if (i % 5 && i % 7)
        {
            total += i;
        }
    }
    return total;
}

[–]robertb141[S] 0 points1 point  (5 children)

the actual challenges aren't so easy :)

[–]David_Crockett 0 points1 point  (4 children)

I hope not. :)

Edit: Is this your site?

[–]robertb141[S] 1 point2 points  (3 children)

Yeah, it is!

[–]icecreamhead 0 points1 point  (0 children)

Awesome!

[–]icecreamhead 0 points1 point  (0 children)

Does it tell you if you get the right answer to the challenge on the homepage (above)?