Little friends, let us work together to write a statistical wages code requirements: (1) non-stop user input is received wages of employees, until the user enters "Exit" will not "enter salary" window pops up (2 ) the user input data is stored in an array

<! DOCTYPE HTML>
<HTML>
<head lang = "EN">
<Meta charset = "UTF-8">
<title> Statistics wages </ title>
</ head>
<body>
<Script>
// define an array arr [], and the array index a
var ARR = [], a = 0;

// do not know the number of recycling cycles do {} while () loop
do {
var INPUT = prompt ( "");
ARR [A] = INPUT; // the value of each input are assigned to the array position corresponding to the index
++ a;
}
the while (! ARR [. 1-a] = "exit") // and the withdrawn position when the value corresponding to the index of the array when the loop exits as
arr.length = a-1; // time arr [a] = "" exit "the array but not the subject of the request" exit "the array value is the number of displayed index may be controlled by the length of the length of the array so that the index can be changed: arr.length = a-1; thus removed the the exit value.
document.write (ARR);
</ Script>
</ body>
</ HTML>

Guess you like

Origin www.cnblogs.com/lvlisn/p/11545301.html