Hello
The following function, 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 form ( 1 + 1 = 11
) is being made.
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);
}