+ 3

help me to get the output

<script language="Javascript" type="text/Javascript"> x=2; for(i=1;i<10;i++){ if (i>5) break; j= i+1; while(j<10){ x=x+i; j +=1; } } document.write(x); </script>

2nd May 2019, 10:48 AM
Erandi Rajasundara
Erandi Rajasundara - avatar
4 Respuestas
+ 12
82
2nd May 2019, 11:15 AM
Mohd Abdul Sameer
Mohd Abdul Sameer - avatar
+ 8
82
2nd May 2019, 11:06 AM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 8
Yes. All values for i are 1,2,3,4,5 when i=6 because 6>5 the 'for loop' stops with 'break' command. 'while loop' is inside brackets of 'for loop'. So, when 'for loop' stops, 'while loop' is not executed anymore
2nd May 2019, 12:36 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 3
Thank Javier Felipe Toribio and 👑Sam👑 😊 i have a question. If (5>5) whole for loop will be stopped ? Otherwise ,,, will it continue till i=10? Give me some clue😒
2nd May 2019, 11:21 AM
Erandi Rajasundara
Erandi Rajasundara - avatar