Skip to content
Advertisement

My code outputs everything right but it doesnt exit after finding out an error

question sample input outputs to check, an input is 221, 1, 7 the output shud be invalid move as the 7th position of 0000221 is 1 already not 0 so it shud be an invalid move which my validation checker does correct except after that it still prints out the whole thing because there is no error with printing it out but i dont want it to print after finding the invalid move.

JavaScript

Advertisement

Answer

Sounds like you want to stop your programme execution after reaching an invalid move. Wrap the programme in a function, and return after the invalid print statement, like:

JavaScript

this would allow the program to skip the rest of the functions and therefore no longer print anything else.

try this:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement