¿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){ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

¿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){

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

3rd Oct 2017, 7:25 PM
andres arroyo
andres arroyo - avatar
2 Answers
+ 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!
3rd Oct 2017, 7:52 PM
Armin Linzbauer
Armin Linzbauer - avatar
+ 1
muchas gracias, voy a probar lo que me escribiste. 👍😊
3rd Oct 2017, 9:18 PM
andres arroyo
andres arroyo - avatar