0
I have the following code,
var resultado;
var numero;
var tamanhoNumero;
var i=0;
function calcular(){
numero = document.form.numero.value;
console.log(numero);
tamanhoNumero = numero.length;
console.log("i = " + i);
for (i = tamanhoNumero; i>=0; i--) {
console.log("i = " + i);
console.log("numero.lenght = " + numero.lenght);
resultado += numero.substring(i, i-1) + '<br>';
}
document.getElementById('saida').innerHTML = resultado;
}
When I fill in the 'output', I would like to clean it before the next operation, this can be done at the beginning of this same function. How to do ?
Don’t just put
resultado = ''
in the first line of the function?– Woss
That’s it, thanks, I was trying with double quotes.
– Vitor Piovezam
Just so we can honor Soen in
numero.lenght
length is poorly written– Isac
Single or double quotes there is no difference. You were possibly missing something else.
– Woss