- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask2.js
More file actions
Latest commit
112 lines (92 loc) · 2.54 KB
/
Copy pathTask2.js
File metadata and controls
112 lines (92 loc) · 2.54 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
functioncheckCharacterType(char){
letasciiCode=char.charCodeAt(0);
if(asciiCode>=48&&asciiCode<=57){
return"The character is a number.";
}
elseif(asciiCode>=65&&asciiCode<=90){
return"The character is an uppercase letter.";
}
elseif(asciiCode>=97&&asciiCode<=122){
return"The character is a lowercase letter.";
}else{
return"The character is not a number, uppercase letter, or lowercase letter.";
}
}
letinputChar=prompt("Enter a character:");
if(inputChar.length!==1){
console.log("Please enter a single character.");
}else{
letresult=checkCharacterType(inputChar);
alert(result);
}
letinteger1=+prompt('Enter your first integer')
letinteger2=+prompt('Enter your second integer')
if(integer1>integer2){
alert('integer1 '+'is greater than '+'integer2')
}
elseif(integer1<integer2){
alert('Integer1 '+'is lesser than '+'integer2')
}else{
alert('Both are equals')
}
letnumber1=prompt('Enter any number \n i will tell you whether it is positive or negative')
if(number1<0){
alert('it is negative')
}
elseif(number1>0){
alert('it is positive')
}
else{
alert('íts zero')
}
letcharacter=prompt('Enter any character (i.e. string of length 1)')
letvowel=['a','e','i','o','u']
letflag='no'
for(i=0;i<vowel.length;i++){
if(vowel[i]==character){
flag='yes'
break
}
}
if(flag=='yes'){
alert(true)
}
else{
alert(false)
}
letcorrect_password='123456'
letpassword=prompt('Enter the following password : '+correct_password)
if(password==''){
alert('Please enter your password')
}
elseif(password==correct_password){
alert('“Correct! The password you entered matches the original password”')
}
else{
alert('Incorrect password')
}
vargreeting;
varhour=13;
if(hour<18){
greeting="Good day";
}
else{
greeting="Good evening";
}
console.log(greeting+'<br> <br>');
lettime=prompt('Enter time in your clock in 24 hours format like : 2200')
if(time>='0000'&&time<1200){
alert('Good Morning!')
}
elseif(time>=1200&&time<1700){
alert('Good afternoon!')
}
elseif(time>=1700&&time<2100){
alert('Good evening!')
}
elseif(time>=2100&&time<=2359){
alert('Good night!')
}
else{
alert('Please enter time in your clock in 24 hours')
}