1
Hello, to not have to repeat the same code 2x and change only the little one I wanted to do 3 different functions, the vectors() and the two that will call the vectors() and then execute their code, but I’m not getting, what I’m 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);
}
Remove the keyword
functionwhen using the function, it is only used in the definition.– user41210
still don’t want to go, in the Chrome log that: scripts.js:13 Uncaught Referenceerror: n is not defined at calcularMaior (scripts.js:13) at Htmlbuttonelement.onclick ((index):34) calcularMaior @scripts.js:13 onclick @(index):34 if you wanted a print: https://prnt.sc/jm6pkp
– Paulo Henrique Rodrigues Grund