1
Hello!
The following function below should add + 1 to id
current, however, is not working, as opposed to adding, is adding + 1.
Example: If the current ID is 1, using the function, the next ID (1 + 1
), should be 2
; However the following is being done (1 + 1 = 11
).
function novo_id(lista) {
var id = 0;
//console.log(id);
if (lista.length > 0) {
for (var i = 0; i < lista.length; i++) {
if (lista[i].id > id) {
id = lista[i].id
}
}
id = id + 1;
}
return (id == 0 ? 1 : id);
}
experiment
id = Number(id) + 1;
– Miguel