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

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

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 Relatório

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 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