I got a newbie question, that is wondering me a bit!
Which way is best? Are there any difference?
Example a
if (number === 1 || number === 2 || number === 3) {
...
}
Example b
if (number === 1) {
...
} else if (number === 2) {
...
} else if (number === 3) {
...
}
As these examples shows, the first example is using way less lines of code, so my first thought is, thats the right way in this case. But are there any benefits in example b?
I'm aware you can use a switch statement too, but I can't with the code I'm sitting with, that made me wonder about this