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

230
Views
Javascript refactoring and cleaning up helper function code

Im working on an app that uses a few helper functions that I've created to format data coming in. Below is the code that I've made. It all works, and does what it's supposed to, but I'm hoping for some help with making the code a bit more efficient.. I feel that it could be cleaned up a bit.

// Convert to Title Case
export function toTitleCase(str) {
  return str.replace(/\w\S*/g, function (txt) {
    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  });
}

// Convert date from ISO-8601 to toDateString without time
export function formatDate(dateData) {
  const date = new Date(dateData);
  const formattedDate = date.toDateString();
  return formattedDate;
}

// Convert date from ISO-8601 to toDateString with time
export function formatDateWithTime(dateData) {
  const date = new Date(dateData);
  const formattedDate = date.toLocaleString();
  return formattedDate;
}
about 4 years ago · Juan Pablo Isaza
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!