What's wrong with this simple code !

79 views
Skip to first unread message

Ashutosh Das

unread,
Nov 30, 2013, 10:32:37 AM11/30/13
to nod...@googlegroups.com
var a = 5 , b = 6 ;
if(a == b){
    console.log("Ad");}
else{
    break;
    console.log("AsdASD");
}


It simply returns
     break;
    ^^^^^
SyntaxError: Illegal break statement

same as continue ......

Scott González

unread,
Nov 30, 2013, 10:36:29 AM11/30/13
to nod...@googlegroups.com
There's nothing for you to break out of. Why did you add that line to your code?


--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jose Luis Rivas

unread,
Nov 30, 2013, 10:38:53 AM11/30/13
to nod...@googlegroups.com

Where's a loop there to use break? Btw non sense to write console.log after trying to stop an if.

Use return.

--

Ashutosh Das

unread,
Nov 30, 2013, 10:59:16 AM11/30/13
to nod...@googlegroups.com
I just want to skip rest of the loop .


You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/Gs8S-B3cEYg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

Jose Luis Rivas

unread,
Nov 30, 2013, 11:04:38 AM11/30/13
to nod...@googlegroups.com

That's not a loop is a conditional

Ashutosh Das

unread,
Nov 30, 2013, 11:13:36 AM11/30/13
to nod...@googlegroups.com
Thanks for the correction .. silly mistake  :/ 
Reply all
Reply to author
Forward
0 new messages