Skip to content

Instantly share code, notes, and snippets.

@weisjohn
Created July 19, 2012 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weisjohn/3147543 to your computer and use it in GitHub Desktop.
Save weisjohn/3147543 to your computer and use it in GitHub Desktop.
simple negated addition problem
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