(SOLVED) Why that function returns NaN?

Hi campers! First of all, thanks.

I´m getting more and more confused with this extremely simple problem. I´m trying to write the less lines as posible, that´s the reason why I´m stucked. I´ve seen that it works with longer code, but the challenge is to reduce it to 2 or 3 lines as much.

I don´t know what I´m doing wrong:

function startcount(){
    var seg = 0;
    var s = document.getElementById(“counter”);
    window.setInterval(function(){
    s.innerHTML = seg++;
    },1000);

\\this function above creates a counter (in seconds)

}function verDato(){
    var freq = 0.13;
    var elDato = document.getElementById(“counter”);
      dato1.innerHTML = Math.round(elDato*freq)
}

\\this function above tries to multiply the actual value of “counter” by var freq and then replace the value of the id=“dato1” with the result of the multiply

Why returns NaN?? I don´t manage at all Math. and .innerHTML rules so well yet. What I´m doing wrong?

Thanks again!

document.getElementById(“counter”); will return an HTMLElement.
not sure if you can do elDato * freq

maybe you meant

elDato.textContent * freq

?

I´ve tried but still returning NaN :roll_eyes: I´m not sure if it´s a notation problem… need to add some brackets?

 var elDato = document.getElementById(“counter”).innerHTML

I reached the solution, so I´ll post it in order to help someone with the same or similar problem… the key is to adding .innerHTML to the bottom :sweat_smile::sweat_smile: