How can I stop additional prompts when I don't need them anymore? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I stop additional prompts when I don't need them anymore?

Whenever I input «no» at the start, the code keeps running. How can I make it stop? https://code.sololearn.com/Wh3X8VQulWAA/?ref=app

24th Oct 2018, 10:30 PM
M. Elle
M. Elle - avatar
1 Answer
+ 1
Your entire code is not that efficient overall, for instance you could just use input.toLowerCase to avoid asking the user to use lowercase. Another thing is that you should put actions in functions, then you also have the option to use the return keyword to exit the function. Another solution is sorround the rest of the prompt with an if: if (input == yes) { } else if (input == no) { }
25th Oct 2018, 4:47 AM
Eldar Bakerman