Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


JavaScript Programming

JavaScript > Code Examples

Array loop, find: Control array : Two dimension array

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
Array loop, find: Control array : Two dimension array var myArray = ["Jhon", "Jenny", "Jean", "Jack"]; for (var i = 0; i < myArray.length ; i++) { alert("Item " + i + " is:" + myArray[i] + "."); } ---------- var nameList = ["Jhon", "Jenny", "Jean", "Jack"]; var ageList = [23, 32, 28, 24]; function ageLookup(name) { for (var i = 0; i < nameList.length ; i++) { if (nameList[i] == name) { return ageList[i]; } return "Could not find " + name + "."; } ---------- function clearTextBoxes() { var allInputs = document.getElementsByTagName("input"); for (var i = 0; i < allInputs.length; i++) { if (allInputs[i].type == "text") { allInputs[i].value = ""; } } } ---------- var salesArray = [[2300, 3105, 2909, 4800], [1800, 1940, 2470, 4350], [900, 1200, 1923, 3810]]; var total = 0; for (var i = 0; i < salesArray.length; i++) { for (var j = 0; j < salesArray[i].length; j++) { total += salesArray[i][j]; } }