Stop code execution? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Stop code execution?

I do not want to learn bad habits so therefore this question👍 Is the code below valid and correctly formatted to stop code execution? Or is it a bypass in some way to prevent code execution? (Are there more options to stop code execution?) var num = 0; function exec1() { if (num == 1) { exec2(); } else { // stop code execution if not equal console.log("STOP exec!") return; } // continue code execution if equal function exec2() { console.log("continue code exec"); } } exec1(); Additional: https://code.sololearn.com/WFViH595HcLe/?ref=app

14th Sep 2018, 12:13 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
1 Answer
+ 5
✓ yes whenever "return;" bring no results and stop further code execution and this is on if else so there are no other places where Code have to work on;
14th Sep 2018, 12:31 PM
Sudarshan Rai
Sudarshan Rai - avatar