- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifelse.js
More file actions
Latest commit
39 lines (32 loc) · 1.09 KB
/
Copy pathifelse.js
File metadata and controls
39 lines (32 loc) · 1.09 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
// Shartli operatorlar bilan ishlash
// learn.javascript.ru saytidagi ifelse operatori masalalari yechimi
// Masala #1 alert operatori ishga tushadi, chunki har qanday bo'sh bo'lmagan satr true qiymat qabul qiladi
// Masala #2
answer=prompt("javascriptning rasmiy nomi nima?",'');
if(answer==='EcmaScript')alert("javob to'g'ri")
elsealert("hali bilmaysizmi? U EcmaScript deyiladi");
//Masala #3:
take=prompt("raqam kiriting",'');
if(take>0)alert('1')
elseif(take<0)alert('-1')
elsealert('0');
// Masala #4
varuser=prompt("Kimsiz?, '');
if(user=='Admin'){
var pass =prompt("Parolni kiriting",'');
if(pass=="Hukmron) { alert("XUSHKELIBSIZ"); }
elseif(pass==null){
alert("Kirish bekor qilindi");
}else{alert("Parol noto'g'ri");}
}elseif(user==null){
alert("Kirish bekor qilindi");
}else{
alert("Men sizni tanimayman);
}
// Masala #5
result=(a+b<4) ? "kichik" : "katta";
// Masala#6
message=(login=="Jamshid") ? "Salom" :
(login=="Admin") ? "Assalomu alaykum" :
(login=='') ? "login kiritilmagan" : '';
alert(message);