Hi Fellow codeCampers. Once more I rely on your knowledge to clarify my confusion.
Below is a code (Somewhat Spoiler), but it doesn’t work. It’s kinda second version of the solution, as I use Short-Circuit conditionals, but with some differences. Can anyone explain what is wrong with it ? I have spent some time looking for typos and other mistakes, but nothing.
> function updateRecords(object, id, prop, value) {
> if( value === ''){ //4
> delete object.id.prop;
> }else if(prop !== 'tracks'){//1
> object.id.prop = value;
> }else{
> object.id.prop = object.id.prop || [];//2 && 3
> object.id.prop.push(value);
> }
> return object;
> }
Just before posting it, I have changed dots to square brackets and it worked !!!
So the only question is -why dots are not accepted ?