Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
how to find if a string includes something in a switch() javascript

i would like to find out if a string contains a certain word using a switch() statement

here is an example of what i want to use that for:

let text = "among"

switch(text.toLowerCase().includes()){
   case "among"
      console.log("not funny")
      break

   default:
      break
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Switch statement evaluates an expression so this code will not work. You could store possible inclusions in an array and loop through the array, then depending on the evaluation output a certain response with a switch statement.

let text = "among"

let words = ["among", "text", "test"]


function test(word, wordArr) {
    for (let w of wordArr) {
        if (w === word) {
            switch (w) {
                case "among":
                    console.log("among word");
                    break;
                default:
                    break;
            }
        }
    }
}

console.log(test(text, words))
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda