I am developing a game in JavaScript where you start with a user input, stored in the variable "controller". The options for the user consists of start to start the game or about to learn about the game. I was going to use the following code
if(controller === "start"){
// Game code sitting here
}
else if(controller === "about"){
// All about the Game
}
else{
// Tells the user again to type start to start or about to learn about the game
}
when I realized that I should maybe use switch cases instead...
So, my question is when to use switch cases instead of if statements and which I should use in this case. I would also like to know if you think I should store my game code in a function and call it if controller is equal to "start" or just have it sitting inside the if statement/switch case as it is atm?