","answerCount":3,"upvoteCount":0,"acceptedAnswer":{"@type":"Answer","text":"a while loop is running until the condition is false (if counter = 10 -> 10 < 10 -> false).\n\ncounter is 0 -> 0 < 10\nresult = 1 * 2 = 2\ncounter = 0 + 1 = 1\ncounter = 1 -> 1 < 10\nresult = 2 *2 = 4\ncounter = 1 + 1 = 2\n-> 2 < 10\nresult = 8\ncounter = 3\n-> 3 < 10\nresult = 16\ncounter = 4\n-> 4 < 10\nresult = 32\ncounter = 5\n-> 5 < 10\nresult = 64\ncounter = 6\n-> 6 < 10\nresult = 128\ncounter = 7\n-> 7 < 10\nresult = 256\ncounter = 8\n-> 8 < 10\nresult = 512\ncounter = 9\n-> 9 < 10\nresult = 1024\ncounter = 10\n-> 10 < 10 is not true -> end loop\n\nprint result -> output: 1024","upvoteCount":4},"suggestedAnswer":[{"@type":"Answer","text":"Williams It is just an arrow sign which I use as a pointer/marker. I also use it to represent a chain.","upvoteCount":3},{"@type":"Answer","text":"Please what is the meaning of - >","upvoteCount":0}]} }
0

Please what is the explanation of this code, it's a JavaScript program

<script> var result = 1; var counter =0; while (counter<10){ result=result *2; counter =counter +1; } document.write(result) ; </script>

5th May 2019, 11:48 AM
Oodo Roland Uchenna
Oodo Roland Uchenna - avatar
3 Respuestas
+ 4
a while loop is running until the condition is false (if counter = 10 -> 10 < 10 -> false). counter is 0 -> 0 < 10 result = 1 * 2 = 2 counter = 0 + 1 = 1 counter = 1 -> 1 < 10 result = 2 *2 = 4 counter = 1 + 1 = 2 -> 2 < 10 result = 8 counter = 3 -> 3 < 10 result = 16 counter = 4 -> 4 < 10 result = 32 counter = 5 -> 5 < 10 result = 64 counter = 6 -> 6 < 10 result = 128 counter = 7 -> 7 < 10 result = 256 counter = 8 -> 8 < 10 result = 512 counter = 9 -> 9 < 10 result = 1024 counter = 10 -> 10 < 10 is not true -> end loop print result -> output: 1024
5th May 2019, 1:05 PM
Denise Roßberg
Denise Roßberg - avatar
M
+ 3
Williams It is just an arrow sign which I use as a pointer/marker. I also use it to represent a chain.
10th May 2019, 9:40 PM
Denise Roßberg
Denise Roßberg - avatar
M
0
Please what is the meaning of - >
10th May 2019, 9:33 PM
Oodo Roland Uchenna
Oodo Roland Uchenna - avatar