Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript dynamic arrays

var input = []; // initialise an empty array
var temp = '';
do {
    temp = prompt("Enter a number. Press cancel or leave empty to finish.");
    if (temp === "" || temp === null) {
        break;
    } else {
        input.push(temp);  // the array will dynamically grow
    }
} while (1);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #dynamic #arrays
ADD COMMENT
Topic
Name
2+2 =