-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
79 lines (74 loc) · 2.53 KB
/
Copy pathapp.js
File metadata and controls
79 lines (74 loc) · 2.53 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
let number = Math.floor(Math.random() * 10) + 1; // The number to guess
console.log(number); // For debugging (to check the random number)
function greetNumber() {
let userinput = document.getElementById("txt01").value; // Get user input
userinput = Number(userinput); // Convert the input value to a number
// Check if the input is a valid number
if (isNaN(userinput) || userinput < 1 || userinput > 10) {
//alert("Please enter a number between 1 and 10.");
Swal.fire({
title: "Please enter a number between 1 and 10.",
width: 600,
padding: "3em",
color: "#716add",
background: "#fff url(/images/trees.png)",
backdrop: `
rgba(0,0,123,0.4)
url("/images/nyan-cat.gif")
left top
no-repeat
`
});
return;
}
// Check the user's guess
if (number === userinput) {
//document.getElementById("hello").innerText = `You win! The number was ${number}.`;
//alert("You win!");
Swal.fire({
title: "Congratulation You Win",
width: 600,
padding: "3em",
color: "#716add",
background: "#fff url(/images/trees.png)",
backdrop: `
rgba(0,0,123,0.4)
url("/images/nyan-cat.gif")
left top
no-repeat
`
});
} else if (number > userinput) {
//document.getElementById("hello").innerText = "Your guess is less than the number.";
//alert("Your guess is less than the number.");
Swal.fire({
title: "Try again , Your guess is Less than the number.",
width: 600,
padding: "3em",
color: "#716add",
background: "#fff url(/images/trees.png)",
backdrop: `
rgba(0,0,123,0.4)
url("/images/nyan-cat.gif")
left top
no-repeat
`
});
} else {
//document.getElementById("hello").innerText = "Your guess is greater than the number.";
//alert("Your guess is greater than the number.");
Swal.fire({
title: "Try again , Your guess is Greater than the number.",
width: 600,
padding: "3em",
color: "#716add",
background: "#fff url(/images/trees.png)",
backdrop: `
rgba(0,0,123,0.4)
url("/images/nyan-cat.gif")
left top
no-repeat
`
});
}
}