Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda