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

184
Vistas
Problem when I press the button I have an error in the console log which says my function is not defined

When you click on the button the Console says:

project3.html:48 Uncaught ReferenceError: findnembers is not defined at HTMLButtonElement.onclick (project3.html:48)

Why is that?

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>project3</title>
</head>
<body dir="ltr">
    <button id="click here to calculate" onclick="findnembers();" type=button>click here to calculate </button>
    <div id='rslt' style='text-align: center;font-size: 1em; font-weight: bolder;' value=""></div>
    <script>
        function sumdigits(num) {
            sum = 0;
            while (num) {
                sum += num % 10;
                num = Math.floor(num / 10);
            }
            return sum;
        }
        function findnembers() {
            var counter = 0;
            var list='<ol>';
            for (let i = 0; i < 9999; i++) {
                var ezer = sumdigits(i);
                if (ezer === 9) {
                list+= "<li>" + i + "</li>";
                 counter++;
                }
            list += "</ol>";
            }
            var print=list+
            <p style='text-align: center;font-size: 1em; font-weight: bolder;'>"The  sum of digits of those number is 9, and they are in the range 0 to 9999 inclusive and their quantity is "{counter}</p>;
            document.getElementById("rslt").innerHTML=print;
        } 
</script>
</body>
</html>```
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

as @kinglish said quoting . it should be like this

 var print=`${list}<p style='text-align: center;font-size: 1em; font-weight: bolder;'>"The  sum of digits of those number is 9, and they are in the range 0 to 9999 inclusive and their quantity is "${counter}</p>`;
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