Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda