I realise this question probably has been asked before. I'm asking this as I don't know what to search for.
Hi, so I've started learning about arrays, but I'm not sure how (or if) they can help me with this problem:
Let's say I want the user to be able to choose what to do within my program. I then write a numbered list to the console:
- Output "a"
- Output "b"
- Output "c"
The user will be asked to enter a number, and the number defines which function the program is going to run. What i want the program to do is instead of having me write this three times and changing out the numbers and letters:
if (numberInput == "1") {
functionA;
}
I just write something that takes the number from numberInput
and then runs the function associated with it.
Again, I know this question probably has been asked a 1000 times before, so I'm wondering if someone has an idea on how I should go forward on searching for the answer. Thanks!