Record collection challenge .whats wrong with my code

I need help with my record collection function
if (prop!=“tracks” && value !=" “){
collection[id][prop] = value;
}
if (prop==“tracks” && collection[id].hasOwnProperty(prop)){
collection[id][prop] = [ ];
}
if (prop==“tracks” && value!=” "){
collection[id][prop].push(value);
}
if ( value = " "){
delete collection[id][prop];
}

You have a space inbetween all your quotes, like this: " ".
You should have no space there, that is it should be ""

If collection[id] has already a "tracks" property you are emptying it with this

1 Like

I’ve changed that but still it displays an error

help me to go about it

This will always execute, as that is an assignment operator you are assigning a value to value not checking it

I already changed it from an assignment operator to == for comparison.

If the object does not have the tracks property you need to create it with a value of an empty array, if instead it does have it already you don’t have to do anything, you just need a small correction to your current code

Your problem is here; your logic is inverted. You want to set the tracks to an empty list if it doesn’t have a tracks property.

Try this:
if (prop==“tracks” && !(collection[id].hasOwnProperty(prop))){

I haven’t looked at the rest of the code hard enough to see if you have more errors in it, but make this fix and see if more tests pass.

no its not working yet

Which tests are failing? Have you tried tracing through your logic, going through each step in your head? Try adding some console.log statements in your code to see which conditions are firing unexpectedly.

All along this the only error am getting whatsoever
After updateRecords(2468, "tracks", "Free") , tracks should have "1999" as the first element

Can you post your updated code?

This is another problem – it should be ===, not =

Don’t write a series of if statements on the same line
Also, please don’t use a screenshot, post your code so it is easier to copy it to test it
Or if you post a screenshot at least include the result of the tests

It seems like it is passing for me if I got your code right. Copy your function and then reset the challenge, paste it back in and run the test again.