In this tutorial learn for loop through an array in JavaScript, for loop in javaScript with print value using with length,.
COMPLETE TUTORIAL
var myString = ["Nakiya","Jack"];
var arrLength = myString.length;
for (var i = 0; i < arrLength; i++) {
console.log(myString[i]);
//Do something
alert(myString[i]);
}
COMPLETE TUTORIAL
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script>
window.onload = function() {
show_random_number();
};
function show_random_number() {
var myString = ["Nakiya","Jack"];
var arrLength = myString.length;
for (var i = 0; i < arrLength; i++) {
console.log(myString[i]);
//Do something
alert(myString[i]);
}
}
</script>
</body>
</html>
</body>
</html>
No comments:
Post a Comment