Jump to content

continue start; break


vmars316
 Share

Recommended Posts

Hello & Thanks;

The following doesn't work, pls, how come ?

<script type="text/javascript">
function myFunction() {
var i = 0;
start: while(i < 3) {
alert("alert box #1");
alert("alert box #2");
i++;
if(i < 3) continue start;
break;
}
</script>
Thanks..vm
Link to comment
Share on other sites

for starters, look at your curly brackets

 

Also, check out the the if tutorial:

 

http://www.w3schools.com/js/js_if_else.asp

 

EDIT:

 

Do you mean continue instead of start?

Edited by niche
Link to comment
Share on other sites

for starters, look at your curly brackets

Also, check out the the if tutorial:

Do you mean continue instead of start?

Thanks,

 

Ok, fixed the curly brackets .

I can't see the if error.

I think I mean continue, so flow will go up to start.

But still no go.

 

<script type="text/javascript">
function myFunction() {
var i = 0;
start: while (i < 3) {
alert("alert box #1");
alert("alert box #2");
i++;
if (i < 3) continue start;
break;
}
}
</script>
Thanks..vm
Link to comment
Share on other sites

Maybe you should describe in words what you actually want or expect this code to do. The whole idea of labels is to allow you to exit a particular loop in a nested set of loops or to continue execution at the top of a particular loop. For a single loop such as your code there is no need for a label.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...