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

74
Visualizações
How do I make names that start with the letter K appear only in the console

i need to make names that start with the letter K appear only in the console

let friends = ["keven", "Khaled", "keiven", 1, 2, "coder", "zein"];
let i = 0;
let counter = 0;


while (i < friends.length) {
    console.log(friends[i])
    i++
    if (friends[i][counter] === friends[i].includes("A")) {
        continue;
    }
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use the forEach syntax to cycle over your array, and then printing only the elements matching your request (so elements that are string and starts with a "k" letter).

friends.forEach((elem) => {
  if(elem.toString().toLowerCase().startsWith("k"))
    console.log(elem)
})
about 4 years ago · Juan Pablo Isaza Relatório

0

  1. loop over the array
  2. get the first letter as lowerCase
  3. check if it equals to 'k'

    const friends = ["keven", "Khaled", "keiven", 1, 2, "coder", "zein"];
    for(let friend of friends){
        if(String(friend[0]).toLowerCase() === 'k'){
            console.log(friend);
        }
    }
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