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

203
Visualizações
How to return more than one thing in if statement?

I want to display all the product which fulfilled a condition.


    if(correctSize === 3 || correctSize === 4) {return  key == "3kw" }
    if(correctSize === 4 || correctSize === 5) {return  key == "4kw"} 
    if(correctSize === 5 || correctSize === 6) {return  key == "5kw" } 
    if(correctSize === 6 || correctSize === 7) {return  key == "6kw" } 
   

but the problem is that it return just one object (the first with return).

  1. there is easy way to say the statement is true if correctSize is from 4 to 6?
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try to create an array of results and push your answers inside. For example:

let results= [];
if(correctSize === 3 || correctSize === 4) results.push("3kw");
if(correctSize === 4 || correctSize === 5) results.push("4kw"); 
if(correctSize === 5 || correctSize === 6) results.push("5kw"); 
if(correctSize === 6 || correctSize === 7) results.push("6kw");
return results;

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