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

210
Views
how to get length of the characters in a array in javascript?

so like imagine I have an array like this

names = ["Alex", "David", "Hanna"]

so I want to get the length of the characters like Alex is 4 characters long and If I get an odd length I want to show that as an output. I can't figure out how to do it.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can use Array.filter method to filter the results


const names = ["Alex", "David", "Hanna"]
names.filter(name => name.length % 2 !== 0) // ['David', 'Hanna']

about 4 years ago · Juan Pablo Isaza Report

0

Welcome Santonu to SO, you can do the following:

const names = ["Alex", "David", "Hanna"];

for (const name of names) {
  console.log(name.length);
}

This will iterate every name of the array and log you the length.

about 4 years ago · Juan Pablo Isaza Report

0

const array = ["Alex", "David", "Hanna"]
array.forEach(item => {if(item.length%2 == 1)  console.log(item)});

See this for loop in javascript.

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!