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

219
Views
target ever second word in a string using map function

Apply the map() function to the variable str so that every second word in the string is converted to uppercase. in javascript.

str = "hello my name is jon and i live in. canada."
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

"hello my name is jon and i live in. canada."
    .split(" ")
    .map((word, idx) => idx % 2 === 0 ? word : word.toUpperCase())
    .join(" ")

The trick is:

  1. Split by spaces.
  2. Map with index, but only use toUpperCase() if idx % 2 !== 0.
  3. Then join back with spaces.
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!