How do I add a "Invalid Argument, Please Try Again" Commands to my code?
In my game, I am trying to add a command that if the user doesn't write a valid argument, it will replay the code. Currently, for the main startup for the code, it has two options attack
and run
. I am trying to make it so if the user puts in an argument that is not one of those two, it will say Invalid Argument, Please enter a valid option
. Can anyone help me with this?
@Coder100 If you haven't noticed, this is clearly a remake of one of your game jam entries in a different language. This was made solely for learning purposes.
and no I am honored that people take inspiration :)
ok looking on to it
https://repl.it/@idrgplayer/MildWorseApplet#index.js
Try my code, is it supposed to be like this.
@idrgplayer if yes then pls mark my answer correct. :)
Put an else
like this:
else {
document.write("not valid")
}
@RYANTADIPARTHI Not working :(
@Hamburgr put the else with an if statement.
Ok, so I would recommend you doing something like:
You can read up on it here