首页 > 代码库 > 逻辑判断或(&&)练习

逻辑判断或(&&)练习

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Title</title>
 6 </head>
 7 <body>
 8 <script>
 9     var num1=15;
10     var num2=18;
11     //1.判断num1是否小于等于30以及num2是否大于等15;
12     var result=num1<=30 && num2>=15;
13     console.log(result);
14     //输出结果为true
15 
16     //2.判断num1是否大于等于30以及num2是否<于等15;
17     var result2=num1>=30&&num2<=15;
18     console.log(result2);
19 
20     //3.判断num1是否小于等于30,以及num2的值赋值为8888;
21 
22     //(翻译):如果num1的值小于等于30的话,那么就将num2的值更改为888;
23     var result4=(num4<=30) && (num4=8888);
24     console.log(result4);
25     console.log(num2);
26 
27     //4.判断num1是否大于等于30,以及num2的值赋值为8888;
28     //(翻译):如果num1的值大于等于30的话,那么就将num2的值更改为888;
29     var result5=(num1>=30) && (num2=888);
30     console.log(result5);
31     console.log(num2);
32 
33 </script>
34 </body>
35 </html>

 

逻辑判断或(&&)练习