Closed Bug 1352856 Opened 7 years ago Closed 6 years ago

continue statement, example 2.

Categories

(Developer Documentation Graveyard :: JavaScript, enhancement)

All
Other
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pvent08, Unassigned)

Details

(Whiteboard: [specification][type:bug])

What did you do?
================
1. run the example
2. found it's an infinite loop
3. need to declare variables i and j if it is to run on VS or other text editor.
4.change condition in second while loop to < instead of >4.

What happened?
==============
you declare j-=1; which makes the loop infinite.  so the output is 'undefined' when using chrome dev console. So you can't see how the 'continue' statement work. On debugging VS Code ignored anything after line 6 'while (j > 4) {' and jumped straight to the console.log statements at the end of the code.  By changing second while condition to j<4 in line 6 and j -= 1; to j += 1; in line 8, the debugger goes through the entire code.

What should have happened?
==========================
should've had an output like:
0
0
1 is odd.
1
2
3 is odd.
3
i = 1
j = 4
1
i = 2
j = 4
2
i = 3
j = 4
3
i = 4
j = 4

Is there anything else we should know?
======================================
It would be nice if the examples are complete with var declarations so those learning can do so more smoothly and less painfully
Component: General → JavaScript
Product: Mozilla Developer Network → Developer Documentation
This example now works: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue#Using_continue_with_a_label
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.