1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8" />5 <title>If Exercise 1</title>6 <Scripttype= "Text/javascript">7 /*8 * Enter Xiao Ming's final results from the keyboard:9 * When the score is 100, ' reward a BMW 'Ten * When the score is [80-99], ' reward a iphone15s ' One * When the score is [60-80], ' reward a reference book ' A * Other time, what reward is not - */ - the /* - * Prompt () can pop up a prompt box with a text box - * User can enter a paragraph in the text box, the function needs a string as a parameter, - * The string will be the prompt text of the prompt box + * - * The user input will be returned as the function's return value, you can define a variable to receive the content + */ A //put the prompt into a loop at while(true){ - //score is Xiao Ming's final grade. - varscore=Prompt ("Please enter Xiao Ming's final result (0-100):"); - //determine if the value entered by the user is legitimate - if(Score>= 0 &&score<= -){ - //satisfying this condition proves that the user's input is legal and exits the loop in Break; - } to + Alert ("Please enter a valid score!!! "); - } the * $ Panax Notoginseng //Judging whether the value is legal - if(Score> - ||score< 0 ||IsNaN (Score)) { the Alert ("pull out and shoot."); + }Else{ A //according to the value of score to decide what reward for Xiao Ming the if(Score== -){ + //reward a BMW - Alert ("BMW, take it ~ ~ ~"); $ }Else if(Score>= the){ $ //reward a cell phone - Alert ("mobile phone, take to play ~ ~ ~"); - }Else if(Score>= -){ the //reward a reference book - Alert ("reference books, take to see ~ ~ ~");Wuyi }Else{ the Alert ("stick a root ~ ~"); - } Wu } - About $ - - - A </Script> + </Head> the <Body> - $ </Body> the </HTML>
JS Basic _while Exercises 2