Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Guess-the-number/Jsish/guess-the-number.jsish
Normal file
34
Task/Guess-the-number/Jsish/guess-the-number.jsish
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
function guessNumber() {
|
||||
// Get a random integer from 1 to 10 inclusive
|
||||
var num = Math.ceil(Math.random() * 10);
|
||||
var guess;
|
||||
var tries = 0;
|
||||
|
||||
while (guess != num) {
|
||||
tries += 1;
|
||||
printf('%s', 'Guess the number between 1 and 10 inclusive: ');
|
||||
guess = console.input();
|
||||
}
|
||||
printf('Congratulations!\nThe number was %d it took %d tries\n', num, tries);
|
||||
}
|
||||
|
||||
if (Interp.conf('unitTest')) {
|
||||
// Set a predictable outcome
|
||||
Math.srand(0);
|
||||
guessNumber();
|
||||
}
|
||||
|
||||
/*
|
||||
=!INPUTSTART!=
|
||||
5
|
||||
9
|
||||
2
|
||||
=!INPUTEND!=
|
||||
*/
|
||||
|
||||
/*
|
||||
=!EXPECTSTART!=
|
||||
Guess the number between 1 and 10 inclusive: Guess the number between 1 and 10 inclusive: Guess the number between 1 and 10 inclusive: Congratulations!
|
||||
The number was 2 it took 3 tries
|
||||
=!EXPECTEND!=
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue