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

148
Visualizações
getting the highest number from array not working

I am trying to get the higest number from an array by looping over the items but the result im getting back is not correct. I also tried using the math.max function but it didn't work. My code is attached below. Any help is appreciated. Thanks in advance.

const lol = ['2', '2211', '9']

var largest = lol[0];


for (var i = 0; i < lol.length; i++) {
  if (largest < lol[i]) {
    largest = lol[i];
  }
}

console.log(largest); //should have been 2211

about 4 years ago · Juan Pablo Isaza
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