Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!