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

287
Visualizações
how to return the lowest number using filter JavaScript? Is there another solution?
let string = '10 200 100 1000 5000';

let arr = string.split(' ').filter(function (a) {

    return a.startsWith(1) && a.length === 2

})

document.write(arr)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

We first split string to each individual piece with (' ') seperator and using map we go over each piece and convert each piece of string to a number with parseFloat(). Let's use parseFloat just in case there might be decimal values. Last step is to spread the array with ... and to return the minimum value from array of numbers using Math.min().

    const string = '200 100 10 1000 567 5000 2314235423532';

    const lowest = Math.min(
      ...string.split(' ').map((piece) => {
        return parseFloat(piece);
      })
    );

    console.log(lowest);

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