
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use Nested While Loop in JavaScript
The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates.
Example
You can try to run the following code to learn how to use nested while loop
<html> <body> <script> var height = 2; var width = 8; var col = 0; var row = 0; document.write("Starting Loop<br> "); while (row < height) { col = 0; while(col < width) { document.write("#"); col++; } document.write("<br>"); row++; } document.write("Loop stopped!"); </script> </body> </html>
Advertisements