DEV Community

Mubasshir Ahmed
Mubasshir Ahmed

Posted on

Answer: FreeCodeCamp: I am stuck on “Record Collection”

this is my answer :

function updateRecords(collection, id, prop, value) {
   if(value === "")
   {
     delete collection[id][prop]
   }
   else if(prop != "tracks" && value != ""){
     collection[id][prop] = value;
   }
   else if (prop === "tracks" ){
     if(value == "Free")
     {
       collection[id][prop[0]] = [1999];
     }
     else{
     collection[id][prop] = [value];
     }
   }

Top comments (0)