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

152
Vistas
I am trying to solve this problem: Write a function onlyLetters that takes a string and returns a new string with the numbers filtered out

I am having some issues solving this problem, and would appreciate if someone could provide guidance on the best way to go about solving it. Thank You.

Write a function onlyLetters that takes a string and returns a new string with the numbers filtered out.

Examples:

onlyLetters('12ab') // => 'ab'
onlyLetters('1xz015')// => 'xz'
onlyLetters('1aasf123ql') // => 'aasfql'

Here is what I wrote:

function onlyLetters(str) {
if(str === isNaN === true) {
    return str;
}

} onlyLetters('12ab');

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

function onlyLetters(input) {
  /*
   *Check for characters 0->9 globally in a regex check 
   *and replace them to '' or nothing.
   */
  return input.replace(/[0-9]/g, '');
}
/*
 * Single line solution (if necessary)
 * let onlyLetters = (input) => input.replace(/[0-9]/g, '');
 */

console.log(onlyLetters('12ab')); // => 'ab'
console.log(onlyLetters('1xz015')); // => 'xz'
console.log(onlyLetters('1aasf123ql')); // => 'aasfql'

How about something as simple as replace? It may be too simple and for that maybe ask another question?

about 4 years ago · Juan Pablo Isaza Denunciar
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