var x = 0;
let armazena=[];
let agregado = document.querySelectorAll("input.entNots");
function armazenador()
{
for (const val of agregado) {
armazena.push(val.value);
}
x++;
elementosAdicionados();
}
function elementosAdicionados()
{
var e = [];
for (var y=0; y<armazena.length; y++)
{
e.push(armazena[y]);
}
console.log(e);
}
<input class="entNots" value="">
<input class="entNots" value="">
<input class="entNots" value="">
<input class="entNots" value="">
<input class="entNots" value="">
<input type="button" id="button1" value="Add" onclick="armazenador();"></input>
Document.querySelectorAll - returns all elements in the document that correspond to the specified CSS selectors, in the class case entNots
push () - adds new items at the end of an array and returns the new length of that array.
for-of - This loop is specific to iterate between the elements of a list. It traverses iterative objects, calling a custom function with instructions to be executed for the value of each distinct object.
Syntax:
for (variavel of iteravel){
declaração;
}
Where:
variável
: at each iteration, a value of a different property is assigned to the variable;
iteravel
: object whose attributes will be iterated.
Example:
let menu = ['segunda - Feijão tropeiro', 'terça - macarronada', 'quarta - Baião de dois', 'quinta - Feijoada', 'sexta - CHOPADA'];
for (let value of menu) {
console.log(value);
}
Take a look at this Medium story, you’ll clear up your doubt and learn more. https://medium.com/@oieduardorabelo/javascript-set-vs-array-quando-e-como-usar-cf05a7a6ce54
– rysahara
Give an example of the desired output and input values.
– user60252
It is not the solution but this loop for is nonsense, so in the first iteration i is already less than i+5
– user60252