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

243
Visualizações
Don't understand this error in javascript within my html file: ',' expected.javascript

I apologize for the silly request, but I am brand new to HTML and JavaScript and am trying to self-teach. My code right now is based off a resource I found that teaches you how to make a timer. My only question is, why does line 16 (var seconds...) come up with the error in the title, specifically with the red line under "var"? Thank you in advance. Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

<p id="demo"></p>

<script>
var x = setInterval(function() {
    var timer = 600;
    var minutes = Math.floor(timer // 60);
    var seconds = Math.floor(timer % 60);
    document.getElementById("demo").innerHTML = minutes + "minutes and " + seconds + "seconds";
    if (timer < 0) {
    clearInterval(x);
    document.getElementById("demo").innerHTML = "EXPIRED"
}
    }, 1000);
</script>
    </h2>
    <a href="html/contact.html">Contact Information</a>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You will probably find this is to do with line 15, being commented out at character 37, I think instead of putting / you've ended up putting // which comments out in js

from my testing, removing the secondary / fixes the issue with the code you pasted

what you had:

    var timer = 600;
    var minutes = Math.floor(timer // 60);
    var seconds = Math.floor(timer % 60);

what works for me

    var timer = 600;
    var minutes = Math.floor(timer / 60);
    var seconds = Math.floor(timer % 60);
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