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

167
Views
live server page loads infinitely

I'm a beginner to coding and more specifically JavaScript and html stuff, and right now I'm just trying to draw a square and make it load. However, when I try to create my server then it just loads the page forever, making it so that I am unable to test my code. Is there any way that I can make it so that my page will actually load? here is my code so far:

html:

<html>
    <canvas id = 'canvas' height = '500' width = '500'></canvas>
    <script src = 'sus.js'></script>
</html>

JavaScript:

const canvas = document.getElementById('canvas')
const ctx = canvas.getContext('2d')

ctx.beginPath()
ctx.strokeRect(0, 0, 500, 500)

let x = 50
while(true){
    ctx.beginPath()
    ctx.fillRect(x, 50, 50, 50)
    x++
}

Thank You!

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

0

I commented and I will answer as well.

while(true) means - run infinitely, because there is no stopping point for the loop.

Try to set the while loop to run until x will be bigger to 200.

while(x <= 200){
    ctx.beginPath()
    ctx.fillRect(x, 50, 50, 50)
    x++
}
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!