-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
73 lines (56 loc) · 1.38 KB
/
script.js
File metadata and controls
73 lines (56 loc) · 1.38 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
// 1.Age verification
const age=Number(prompt("enter your age"));
if(age<18){
alert("you are allowed to enter");
}else{
alert("you must be 18 or older");
}
// 2.confirm before deleting
const result=confirm("are you sure you want to delete this item");
if(result===true){
alert("item deleted successfully");
}else if(result===false){
alert("action canceled");
}
// 3.even or odd checker
const Num=result(prompt("enter your number"));
if(Number%2===0){
alert("the number is even");
}else {
alert("the number is odd");
}
// 4.favorite color response
let color=result(prompt("what is your favorite color"));
if(color==="blue"){
alert("wow blue is cool");
}else if(color==="red"){
alert("red is full of energy");
}else{
alert("that is a nice color too");
}
// 5.simple calculator
let num1=Number(prompt("enter the first number"));
let num2=Number(prompt("enter the second number"));
let operation=prompt("enter an operation(+,-,*,/)");
if(operation==="+"){
result=num1+num2;
}
else if(operation==="-"){
result=num1-num2;
}
else if(operation==="*"){
result=num1*num2;
}
else if(operation==="/"){
result=num1/num2;
}
else {
alert("invalid operation");
}
// 6.guess the secret number
const secretnumber=7;
if(inputnumber===true){
alert("congratulations you guessed it");
}else if(inputnumber===false){
alert("wrong guess try again");
}