Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!