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

182
Views
JavaScript String Reverse and Capitalized

I am looking for a simple solution to build Javascript a function through which I can reverse a word or a string.

I have gone through .split('').reverse().join('') solution from the community to reverse it correctly but now I am stuck on Capitalizing on Each First Character.

let ar = "looking for opportunities"
const a =(ar)=> {return ar.split('').reverse().join('')}

and then I am stuck. I need a solution that can serve both sentence and word.

Required Output : seitinutroppO roF gnikooL

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

0

Use regex.

let ar = "looking for opportunities"
ar = ar.replaceAll(/\w\S*/g,
    function(txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    }
)
const a =(ar)=> {return ar.split('').reverse().join('')}

This matches all characters after a space, then replaces it with an uppercase version.

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!