Today I went to see hints and got 90% of it
function updateRecords(records, id, prop, value) {
if(value === '')
delete records[id][prop];
if(prop !== 'tracks' && value !== ''){
records[id][prop] = value
}
if(prop == 'tracks' && value !==''){
if(!records[id].hasOwnProperty('tracks')){
records[id]['tracks'] = [];
records[id]['tracks'].push(value);
}
}
return records;
}
What shocks me most, why I was making it so complex like if(records[id][props] === value)
thinking it will check if(records[id][props] === '')
. My question now would be, why people like me make it so complated and is it normal, what is best way to approach a problem especially complex one.