Record collection. Pls help to find a mistake

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;
>   }else if(prop !== 'tracks'){//1 
> = value;
>   }else{
> = || [];//2 && 3
>   }
>   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 ?

Dot notation only works with the exact name of the property. If the name of the property is stored in a variable, then you need to use bracket notation.

Since your solution works with that change, I went ahead and added spoiler tags.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.