Menu
This code works as expected, but I looks amateurish to me. Its purpose is to convert at form into a JSON string.
The simple task is to not add the “id” if it is a “new” record.
Like pseudocode: **if it is a new record skip id
“`
formData.forEach(function(value, key) {
switch (action) {
case “new”:
if (key != mod_id) {
object[key] = value;
}
break;
default:
object[key] = value;
}
});
I wonder if it could be simplified without losing readability?