I’m thinking about a game where it asks the layer a question and using switch statement to make it an interactive game. I know how to use switch statements but how to I take the answer from a switch statement and have a different outcome or follow up question depending on the answer? Thanks!!
Other question. When someone answers How do I make the text from that case appear on screen?
You would put the code blocks inside the cases.
You would use console.log()
or document.write()
.
It there a way to make two answers share the same feedback? Like if someone types 2 different things it gives them the same response?(IE have two cases and one response)
I believe you would do it like:
switch(stuff) {
case 5:
case 4:
var pi = 3.14159;
break;
}