Reputation: 5
So I want to solve the Project Euler Q1 through Javascript (because it's the only language I know-- I'm a beginner), and I don't know how to display the outcome of my code other than through HTML. I googled around and wrote this code combining HTML and Javascript, and ran it under the Brackets software, but nothing is showing up. Can someone help me?
/* If we list all the natural numbers below 10 that are multiples of 3
or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the
sum of all the multiples of 3 or 5 below 1000. */
function math() {
var belowThousand = [];
var sum = 0;
for (var i=1; i<1000; i++) {
if (i%3===0||i%5===0) {
belowThousand.push(i);
sum += i;
}
}
console.log(sum);
}
math();
Upvotes: 0
Views: 73
Reputation: 517
To see the results of
console.log()
you need to press "F12" in your browser and go to "console".
You can also do a
alert("TEXT");
and it will show as an alert.
Upvotes: 2