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

155
Views
How can I convert Snake case into Start case?

I have an array of strings with values in the Snake case.

I need them to map some inputs.

How can I convert 'some_string' into 'Some String'?

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

0

  1. map() over the input array

    1. split('_'): Convert string into an array on each _
    2. map() the array to make each first char uppercase
    3. join(' '): Convert the array back to a string, joined on a space ( )

const inputArray = [ 'some_string', 'foo_bar' ];
const outputArray = inputArray.map((input) => (
  input.split('_').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(' ')
));

console.log(outputArray);

Input array:

[ 'some_string', 'foo_bar' ];

Will produce:

[
  "Some String",
  "Foo Bar"
]
about 4 years ago · Juan Pablo Isaza Report

0

You can Array.prototype.map() your array doing String.prototype.replace() with Regular expressions:

const arr = ['some_string', 'foo_bar']
const result = arr.map(
  s => s
    .replace(/_/g, ' ')
    .replace(/^\w|\s\w/g, l => l.toUpperCase())
)

console.log(result)

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!