Created
July 19, 2012 23:13
-
-
Save weisjohn/3147543 to your computer and use it in GitHub Desktop.
simple negated addition problem
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 operands = "", operation = ""; for (var i = 0; i < 10; i++) { operands += "- + "; operation = '1 + ' + operands + '1'; console.log(operation + ": " + eval(operation) ); } | |
/* | |
1 + - + 1: 0 | |
1 + - + - + 1: 2 | |
1 + - + - + - + 1: 0 | |
1 + - + - + - + - + 1: 2 | |
1 + - + - + - + - + - + 1: 0 | |
1 + - + - + - + - + - + - + 1: 2 | |
1 + - + - + - + - + - + - + - + 1: 0 | |
1 + - + - + - + - + - + - + - + - + 1: 2 | |
1 + - + - + - + - + - + - + - + - + - + 1: 0 | |
1 + - + - + - + - + - + - + - + - + - + - + 1: 2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment