Skip to content

Instantly share code, notes, and snippets.

@AyaMorisawa
Created November 6, 2015 13:55
Show Gist options
  • Save AyaMorisawa/921c3d2a05542bdaca68 to your computer and use it in GitHub Desktop.
Save AyaMorisawa/921c3d2a05542bdaca68 to your computer and use it in GitHub Desktop.
var p = console.log.bind(console);
var q = require('readline-sync').question;
var r = () => Math.floor(Math.random()*15)+1
var i = 1;
for(;;) {
var x = r();
p(`(${i}) ${Math.pow(x, 2)}`);
var a = parseInt(q('Input the answer: '));
var c = a === x;
p(c ? 'Good!' : `Bad: The correct answer is ${x}`);
i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment