Here’s an example with two loops, outer and inner −
Example
let demoForLoop = ()=>{
for(var outer=1;outer<100;outer++){
for(var inner=1;inner<=5;inner++){
if(outer==3){
return 'THE OUTER VALUE IS EQUAL TO 3 INSIDE THE LOOP';
}
}
}
return 'OUT OF THE LOOP';
}
console.log(demoForLoop());To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo105.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo105.js THE OUTER VALUE IS EQUAL TO 3 INSIDE THE LOOP