if else circulation
var NUM = prompt ( " Enter a number: " ); behind else not increase determination condition, else the final output in a multi-condition IF (NUM> = 80 && NUM <= 100 ) { Alert ( " you learn good, Come on! " ); } the else IF (NUM> = 60 && NUM < 80 ) { Alert ( " good " ); } the else IF (NUM> = 50 && NUM < 60 ) { Alert ( "It is almost, come on . "); } The else IF (NUM> 0 && < 50 ) { the else ( " hard efforts, do not be lazy " ); } the else { Alert ( " Your input is wrong " ); }
<Script type = " text / JavaScript " > / * user to input 1-7, judgment of the week * / var NUM = prompt ( " Please enter a number between 1-7: " ); and if the difference, switch only can write the value / * the string to type int * / NUM = the parseInt (NUM); Switch (NUM) { Case . 1 : Alert ( " Monday " ); BREAK ; Case 2 : Alert ( " Tuesday " ); BREAK ; Case 3 : Alert ( " Wednesday " ); BREAK ; Case 4 : Alert ( " Thursday " ); BREAK ; Case 5 : Alert ( " Friday " ); BREAK ; Case 6 : Alert ( " Saturday " ); BREAK ; Case 7 : Alert ( " seven weeks " ); BREAK ; default : Alert ( " you entered incorrectly, please re-enter " ); break ; } let the user inputs 1 - . 7 , if the displayed work day 1-5, if 6- seven days rest in display termination determination using a break, will be omitted Analyzing intermediate
var num2 = prompt ( " Please enter the date " ); num2 = the parseInt (num2); Switch (num2) { Case . 1 : Case 2 : Case . 3 : Case . 4 : Case . 5 : Alert ( " days " ); BREAK ; Case 6 : Case 7 : Alert ( " day of rest " ); bREAK ; default : Alert ( " please re-enter " ); BREAK ; }
</ Script>
do while performing the first determination
Circulation print array
var i=1; do{alert(i,i++)}; while(i<=4);