-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.2(Num_min_max).js
More file actions
27 lines (21 loc) · 1.08 KB
/
2.2(Num_min_max).js
File metadata and controls
27 lines (21 loc) · 1.08 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
/* Attention prompt reçoit une chaîne de caractères. pour transformer les chiffres interprétés en lettres par prompt, il faut ajouter new Number devant la fonction (entre parenthèses) */
/*Ask the user to enter three numbers: min, max and current. Display if current is between min and max.
Bonus: if min is greater than max, display an error message to explain the user he's doesn't understand anything then exit the program. (It must not ask any other question.)*/
let min = new Number(prompt("Enter a first number"));
/* Autre manière de formater la chaîne de caractères en nombre*/
let max = prompt("Enter another number");
max =
parseInt(
max
); /* ==> transforme une chaine de caractères "string" en nombre entier*/
if (min > max) {
alert("You're second number must be bigger than the first one");
} else {
let current = prompt("Enter you're favourite number");
if (current >= min && current <= max) {
alert("You're favourite number is between " + min + " and " + max);
}
else {
alert("You're favourite number is not between " + min + " and " + max);
}
}