Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
Can i use something similar on the switch with node.js?

Can i use something similar on the switch with node.js?

let = "aggsfg";
if (s[0] == "a" || s[0] == "e" || s[0] == "i" || s[0] == "o" || s[0] == "u") {
    console.log("vogais");
} else if (s[0] == "b" || s[0] == "c" || s[0] == "d" || s[0] == "f" || s[0] == "g") {
    console.log("consoantes1");
}
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

let s = "aggsfg";

if ('aeiou'.includes(s[0].toLowerCase())) {
  console.log("vogais");
} else if ('bcdfghjklmnpqrstvwxyz'.includes(s[0].toLowerCase())) {
  console.log("consoantes1");
}

You had an error when declaring the variable s.

over 4 years ago · Santiago Trujillo Denunciar

0

Node does have a switch statement. See here.

over 4 years ago · Santiago Trujillo Denunciar

0

You can still compress your code using if and includes. But this is how you can do it with switch

let s = "aggsfg";

switch(s[0]) {
  case "a" || "e" || "i" || "o" || "u":
    console.log("vogais")
  case "b" || "c" || "d" || "f" || "g":
    console.log("consoantes1")
}

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda