In this example, we will see for loop iteration. We have taken one blank array. We will push the values in this array using for loop. Below is the complete example of this action.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>For Loop in JavaScript</title>
</head>
<body>
<script>
var myArray = [];for(let i = 0; i<=5; i++){
myArray.push(i);
}console.log(myArray);
//this will print
//[0,1,2,3,4,5]
</script>
</body>
</html>
Hope you enjoyed this article. You can learn Javascript Mcqs in this website to practice questions.