+ 1
How do you end certain code if a condition is true or false in JavaScript?
Hi, this is my first post, I hope you like it! https://code.sololearn.com/WNhn4QxPL09P/?ref=app
4 Respuestas
+ 1
You can use 'return;' to end the running function. Plus, you can return data if it's called with another function, like
return true;
or
return 'the process was stopped';
+ 4
break; if you mean loops
+ 1
I don't mean in loops I mean a if condition is true.
+ 1
Just don't execute any code after that. Place the password request and check, inside the if-statements valid outcome.
Use this logic (I don't advise using this type of code, but I'm not going to do your work for you :P)
if (userValid){
if (passValid){
alert("shit checks out");
} else {
alert("incorrect");
}
} else {
alert("incorrect");
}