What is better for this situation? array, switch st. or something else? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

What is better for this situation? array, switch st. or something else?

https://code.sololearn.com/cYgeaK9110XM/?ref=app

6th Jun 2020, 1:55 PM
Edward MalaCu
Edward MalaCu - avatar
2 Respuestas
0
From my experience, I would say arrays can be a better option. Mainly because of less code. Followed by - Switch - If/ if else/ else For example if you wanted to do months, you would have to do 12 switch statements. Taking up much code. An array can contain all the months probably in just a few lines of code.
6th Jun 2020, 2:12 PM
Raul Sanchez
Raul Sanchez - avatar
0
I would prefer a dictionary.
6th Jun 2020, 2:20 PM
JaScript
JaScript - avatar