programming-examples/js/_Basic/Write a JavaScript program where the program takes a random integer between 1 to 10, the user is then prompted to input a guess number..js

7 lines
269 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
// Get a random integer from 1 to 10 inclusive
var num = Math.ceil(Math.random() * 10);
var gnum = prompt('Guess the number between 1 and 10 inclusive');
if (gnum == num)
alert('Matched');
else
alert('Not matched, the number was ' + num);