Created
August 8, 2014 06:29
-
-
Save mfrohberg/ff032323bf695401240d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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