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

167
Vistas
How can I display "-" as long as string length in textbox?

I have this list:

let teams = [
  "real madrid",
  "barcelona",
  "milan",
  "inter",
  "juventus",
  "manchester united",
  "manchester city",
  "liverpool",
  "arsenal",
  "chelsea",
  "bayern munich",
];

I wrote code for choose random item from this list but I want display "-" as long as item length.

For example: choose real madrid ... I want this - - - - - - - - - - in the text box.

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

0

Use String.prototype.replace() with a small RegExp that will match any non-space character \S, and replace it with a hyphen - (PS: g stands for global replace)

const str = "Real Madrid";

const hyphenated = str.replace(/\S/g, "-");
console.log(hyphenated);

Happy hangman-ing!

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