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

95
Views
SyntaxError no detectado: palabra reservada de modo estricto inesperado

He estado buscando durante un tiempo qué significa este error (error: Uncaught SyntaxError: palabra reservada en modo estricto inesperado), o cómo solucionarlo, pero no puedo encontrar nada, así que esperaba que alguien aquí pudiera ayudar. Por cierto, me voy a la cama con esto, así que solo leeré las respuestas (si las hay) mañana.

Aquí está la línea que me da el error:

 for (let i = 0; i < 10; i++) { //(And then the code)

PARA PERSONAS QUE NECESITAN CONTEXTO:

 const canvas = document.getElementById('canvas1'); const ctx = canvas.getContext('2d'); class background { draw(){ ctx.fillstyle = 'green'; ctx.beginPath(); ctx.fillRect(0,10,800,500); ctx.fill(); ctx.closePath; }; }; const Backdrop = new background(); Backdrop.draw(); class artist { for (let i = 0; i < 10; i++) { draw(){ ctx.fillStyle = 'lime'; ctx.beginPath(); ctx.fillRect(0+i,10,20,15); ctx.fill(); ctx.closePath; }; }; }; const box = new artist(); box.draw();

Ok enviar ayuda, gracias!!

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

0

Como comentó @Barmar, puede usar el bucle for dentro de su draw() .

Aquí hay un ejemplo de trabajo:

 const canvas = document.getElementById('c') canvas.style.background = 'black' const ctx = canvas.getContext('2d') class artist { draw() { ctx.fillStyle = 'lime' for (let i = 0; i < 10; i++) { ctx.fillRect(10 + i * 30, 30, 20, 15) } } } const box = new artist() box.draw()
 <canvas width="400px" height="170px" id="c"></canvas>

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!