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

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

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