Hello, to not have to repeat the same 2x code and change only the end I wanted to do 3 different functions, the vectors () and the two that will call vectors () and then execute their code, but I'm not What am I doing wrong?
var i;
function vetores() {
var n = new Array(10);
for(i = 0; i < 10; i++) {
var input = "input";
var inputNumero = "" + i.toString();
var inputId = input.concat(inputNumero);
n[i] = document.getElementById(inputId).value;
}
}
function calcularMaior() {
function vetores();
var max = Math.max(...n);
alert("Maior valor: " + max);
}
function calcularMenor() {
function vetores();
var min = Math.min(...n);
alert("Menor valor: " + min);
}