Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda