<>1. Syllabus

* prompt() Application of the method
* if-else Definition and application of statement
<>2.1 prompt() method

* Look at the code below : var s = prompt(" Please input what you want to say :"); alert(s);
* prompt() method : It is used to display the information prompt input box that can prompt the user for input .
* prompt() Content in parentheses : Prompt the user to enter the corresponding content .
* prompt() The return value of the method is what you enter in the input box .
* Declare variables s, Used to receive user input information .
* The information entered by the user is displayed in the warning box .
<>2.2 receive data —— Age

* Declare variables age, Age of receiving user input , The code is as follows : var age = prompt(" Please enter your age :");
* The age entered by the user is displayed on the warning box , Using string concatenators "+", The code is as follows var age = prompt(" Please enter your age :"); alert(" My age is :"
+age);
* input 24, Click OK to display on the warning box “ My age is :24”, The operation effect is as follows

<>2.3 if-else sentence

* if-else The grammatical structure of is as follows : if(1){ 2 }else{ 3 }
* 1 Where is the judgment condition ,1 The judgment condition is true( really ) Time , implement 2 Code at , If 1 The judgment condition is false( false ) When the 3 Code at
* If score exceed 90 branch , Exemption from Holiday Assignments , Otherwise, the homework will be doubled , The code is as follows var score = prompt(" Please enter your score :"); if(score
> 90){ alert(" Exemption from Holiday Assignments !"); }else{ alert(" Holiday homework doubled !"); }
* Declare variables score Receive the information entered in the message prompt box
* judge score>90 Is it true :
score greater than 90, The judgment condition is true, Is displayed in the warning box “ Exemption from Holiday Assignments “,score Less than or equal to 90, The judgment condition is false, Is displayed in the warning box “ Holiday homework doubled !".
<>2.4 if-else Practical use of sentences

* If PM2.5 exceed 300, School holidays , Otherwise, go on to school
* Declare variables pm25, Receive the information input by the user in the message prompt box , The code is as follows : var pm25 = prompt(" Please enter PM2.5 Value of :");
* use if-else sentence , judge pm2.5 Is the value of more than 300, The code is as follows var pm25 = prompt(" Please enter PM2.5 Value of :"); if(pm25
> 300){ alert(" School holidays "); }else{ alert(" Keep going to school "); }
be careful : Points cannot be used in variable naming ( . )

<>2.5 if-else The practical application of sentence in aircraft war

* Interval time to , A bullet fired , Otherwise, no launch , The code is as follows var intervalTime = prompt(" Please enter the interval between firing bullets "); var start =
2400; var end = 2850; if(end-start > intervalTime){ alert(" Firing bullets "); }else{ alert(
" No bullets "); }
* Declare variables intervalTime, It stores the interval time of firing bullets entered by the user in the information prompt input box .
* statement start and end, Store the start time and end time of bullet firing respectively .
* stay if-else Judge the end time in the statement (end) And start time ( start) Is the difference greater than the interval time ( intervalTime).
* If end-start> intervalTime by true, In the warning box, the shot will be displayed , If end- start>
intervalTime by false, No bullets will be displayed in the warning box .

Technology
©2019-2020 Toolsou All rights reserved,
c Language implementation 《 Student management system 》 No hole is the future of mobile phone ? There are still many problems to be solved Junior , A little sense , Just for mutual encouragement How to use Vue Used in Echarts Visual Library The 11th Blue Bridge Cup Java The second provincial competition B Group part Python- be based on OpenCV Contour fill for flooding algorithm hole filling 【C#】 The realization of student achievement information management system List Common interview questions in the collection and simple ideas China Mobile Science Popularization : Why do mobile networks call “ Cellular mobile network ”【Golang Basic series 10 】Go language On conditional sentences if