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

212
Views
Uso de emoji en bucles en JavaScript

Actualmente estoy escribiendo un JavaScript que necesita mostrar una tabla de multiplicar. Sin embargo, con la salida, debe haber emojis en lugar de números. Por ejemplo, en lugar de 1 x 2 = 2, debe ser 1 x 'emoji' 'emoji' = 2.

Este es mi código JavaScript actual:

 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)); } }

Realmente agradecería si alguien pudiera darme consejos sobre cómo puedo responder esto. ¡Gracias!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Como mencionó @CBroe en su respuesta, puede usar la función .repeat() de String .

Echa un vistazo aquí: 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

Necesitas encontrar el valor Unicode del emoji

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

aquí puedes ver que el unicode es U+1F438

luego use String.fromCodePoint() para hacer que JS lo muestre como un emoji real y repítalo con 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!