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

213
Vistas
Using Emoji's in Loops in JavaScript

I am currently writing a JavaScript that needs to display a multiplication table. However, with the output, there needs to be emojis instead of numbers. For example, instead of 1 x 2 = 2, it needs to be 1 x 'emoji' 'emoji' = 2.

This is my current JavaScript code:

function generate() {
  var input = document.getElementById("value1");
  var value = Number(input.value);

  for (var i = 1; i <= 10; i++) {
    document.write("<br />" + value + " x " + i + " = " + (value * i));
  }
}

I would really appreciate it if anyone could give me pointers as to how I can answer this. Thank you!

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

0

As @CBroe mentioned in their response, you can use the .repeat() function of String.

Have a look here: https://codepen.io/Rebouben/pen/MWoGwmM

    const frog = String.fromCodePoint(0x1F438);

    var num1 = 3;

    for(var i = 1; i <= 10; i++){
      console.log(num1+" x "+frog.repeat(i)+" = "+(num1 * i)); 
    }
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to find the unicode value of the emoji

https://unicode-table.com/en/1F438/

here you can see that the unicode is U+1F438

then use String.fromCodePoint() to make JS display it as an actual emoji and repeat it with String.repeat()

const emojiUnicode = 0x1F438;
let repeatedString;
for(var i = 1; i <= 10; i++){
    repeatedString = String.fromCodePoint(emojiUnicode).repeat(i);
    document.write("<br />" + num1 + " x " + repeatedString + " = " + (num1 * i)); 
}
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