Skip to content

Instantly share code, notes, and snippets.

@mfrohberg
Created August 8, 2014 06:29
Show Gist options
  • Save mfrohberg/ff032323bf695401240d to your computer and use it in GitHub Desktop.
Save mfrohberg/ff032323bf695401240d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
var num = 0;
var arr = [];
Array.prototype.sum = function() {
var a = this[0];
for (var i = 1; i < this.length; i++) {
a = a + this[i];
}
return a;
};
while (num < 999) {
num++;
if (num % 3 === 0 || num % 5 === 0) {
arr.push(num);
}
}
console.log(arr.sum());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment