¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
¿Cómo pongo varios valores en un if? Por ejemplo, que se pueda sacar un valor de tres valores. Ejemplo: If ( numero = 1,2,3){
2 Respuestas
+ 3
Lo siento, no hablo español muy bien. Pero sé lo suficiente para entender su pregunta. Por favor, traducir el resto de mi respuesta si no habla inglés:
What you would like to do isn't possible the way you probably think. There are some ways around, though:
You can check if the number is in an array of other numbers:
if(number.inArray([1,2,3,4])) {...}
or you can use logical operators:
if(number = 1 OR number = 2 OR number = 3 ... ) {...}
I hope this helps! You'll have to adapt this to your preferred programming language, of course!
+ 1
muchas gracias, voy a probar lo que me escribiste. 👍😊