Created
December 11, 2013 06:26
-
-
Save wand125/7905873 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
problem = "For theNumber in 0 to 100, if theNumber is divisible by 3 and theNumber is divisible by 5 then print 'FizzBuzz' else if theNumber is divisible by 3 then print 'Fizz' else if theNumber is divisible by 5 then print 'Buzz' else print theNumber."; | |
eval(problem.replace(/\./g,'').replace(/For (.*) in (\d+) to (\d+),/g,'for($1=$2;$1<=$3;$1++)').replace(/if (.+?) then/g,'if ($1)').replace(/print ([\w']+)/g,'console.log($1);').replace(/and/g,'&&').replace(/is divisible by (\d+)/g,'%$1==0')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment