I'm trying to do an exercise where I have to get 5 names in 5 different input, store them in an array and print them in the same fields but in the reverse order they were.
function inverteNomes(){
var nome1 = document.getElementById("txtNome0").value;
var nome2 = document.getElementById("txtNome1").value;
var nome3 = document.getElementById("txtNome2").value;
var nome4 = document.getElementById("txtNome3").value;
var nome5 = document.getElementById("txtNome4").value;
var arrayNomes = [nome1, nome2, nome3, nome4, nome5];
var invertido = arrayNomes.reverse();
for(var i = 0; i < 5; i++){
var nome = document.getElementById("txtNome" + i);
nome.innerHTML = invertido[i];
}
}