I'm giving the first Project Euler question a go: "sum of all the multiples of 3 or 5 below 1000".
I tried running the Javascript portion in jsfiddle as standalone Javascript but nothing happened when I press run. Then I tried putting it in an HTML file and opened it in Chrome and nothing happened. I don't know if there's something about running Javacript (such as using HTML) or something is wrong with my code.
<!DOCTYPE html>
<html>
<head>
<title></title>
<head>
</head>
</head>
<body>
<p>ha</p>
<script>
var solution1 = function(input){
var sum = 0;
for(var i = 1; i < input; i++){
if(i % 3 === 0){
sum += i;
}
else if(i % 5 === 0){
sum += i;
}
return sum;
};
var input = 1000;
console.log(solution1);
</script>
</body>
</html>
console.loglogs your output into the console, not the webpage itself.pelement an id ofoutput, and then use the DOM API to update its contents:document.getElementById('output').innerHTML = input;