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

193
Vistas
How i can print this in one?

I would like to know, how I can write this in one line with the symbol of dollar($) separating each word and with this symbol in the end?I've tried to change " " to $ with replace - no success. In this example it is printing $ before every word but still in a column :/

class Add {
  constructor(...words) {
    this.words = words;
  }
  print() {
    var a = this.words;

    for (let v of a) {
      v = "$" + v;
      console.log(v);
    }
  }
}

var x = new Add("hehe",
  "hoho", "haha", "hihi",
  "huhu");

var y = new Add("this", "is",
  "awesome");

var z = new Add("lorem",
  "ipsum", "dolor", "sit",
  "amet", "consectetur",
  "adipiscing", "elit");

x.print();
y.print();
z.print();

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

0

Unless you need the object for other things, put the strings in an array and use array.join() with '$' as the join argument, and concatentate ? to the end.

Working snippet:

let x = ["hehe", "hoho", "haha", "hihi", "huhu"];

console.log(`${x.join('$')}?`);

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