-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.js
47 lines (31 loc) · 1.04 KB
/
4.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//1 take an input from user
//2 compare the input from user with random number
//3 If ((input no = genrated no)) display "congrats number guessed is correct"
//4 If not then keep asking the number unitl the ((input no = generated no))
let n = Math.floor(Math.random() * 100) + 1 //ramdom no generator
// let i= parseInt(prompt(("Enter your number: ")));
let counter = 0;
do{
var i= parseInt(prompt(("Enter your number: ")));
counter++
if(i<n){
alert("Number enterd is less than generated")
}
if(i>n){
alert("Number enterd is greater than generated")
}
}while(i!==n)
alert("Congrats the number enterd is correct")
alert("your score is:"+counter)
// while(i<100){
// if(i<n){
// alert("The number you guessed is less then generated number")
// }else
// if(i>n){
// alert("The number you guessed is greater then generated number");
// }
// else {
// alert("Congrats number guessed is correct")
// }
// break
// }