Can anybody help me with this lesson!

i can’t solve it please help !!

Please post what code you have tried to write so far. We can’t help if we don’t know what you’ve tried.

function updateRecords(records, id, prop, value) {

if(prop !== 'tracks' && value !== ""){

  records[id][prop]= value;

} else if(prop === 'tracks' && records[id].hasOwnproperty("tracks") === false) {

  records[id][prop] = value; 

} else if(prop === 'tracks' && value !== "") {

  records[id][prop].push(value);

} else if(value == "") {

  delete records[id][prop];

}
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Two problems here.

  1. Where did checking for the value to not be an empty string go?

  2. The tracks property must be an array. This is not an array.

could you please simplify ! … i can not get it

I don’t really know how to say that much simpler. What is confusing about what I said? How can I clarify?

You stopped checking value !== "" in the part I quoted.

You are not making the "tracks" property into an array in the part I quoted.

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