For Loop through an array in JavaScript

In this tutorial learn for loop through an array in JavaScript,  for loop in javaScript with print value using with length,.

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

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...