Record Collection again

@MrBondx Thank you very much I corrected that but I’m receiving the same errors

Well, on that same condition you’ve got an empty array. Is that the requirement? And on the next condition you use arr.push - it will probably throw an error ‘arr is not defined’

@MrBondx Thank you. I still have issues I see.
The empty array is a requirement. And the arr in the next condition doesn’t throw an error at all. In fact the challenge seems to be working with no syntax errors until I run the tests.
Guess I’ll have to study it better. Thanks.
P.S.: I replaced the “arr” with “object[id][prop]”. Same.

only one statement will execute in a if/else if/else chain - you are making the empty array and doing nothing with it

not only that, seeing that the condition is object[id].hasOwnProperty("tracks"), if the tracks property is present, you are overwriting it

1 Like

@ilenia Thank you for your patience ieahleen. I added value to the empty array, I guess I’ll have to think better what property I have to check.
But talking in general, I’m better off than before, don’t you think? As I said, I still have issues but not so disastrous as before.
I’ll keep on studying and studying.
Thank you.

I can’t make a comparison, I don’t remember your previous attempts

I see some logic difficulties, those will get better with practice

1 Like

@ieahleen Thank you! It’s good to know that if I try hard I’ll make it. Else if I don’t, I won’t.

“If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it”

Remember to add value to it!

Also, here:


You need to push value instead of “tracks”.

@Frakkoz Thank you, I had done the adding of value but didn’t add it here!
I changed it to push value instead of “tracks”.
I’m still receiving the same errors though I have no syntax errors.
So thanks, I’ll keep on trying!

I just noticed on last thing:

else if (prop === "tracks" && object[id].hasOwnProperty("tracks")) {

On this line, the second condition should return false.
One way of achieving this could be by adding a ! before it, like this:

else if (prop === "tracks" && !object[id].hasOwnProperty("tracks")) {
1 Like

@Frakkoz I was turning my head around just to figure out where I had to add a “!”! Thank you so much! I’ll check the inverted commas too, thanks to the changes you suggested I’m receiving less errors!

1 Like

Well, @Frakkoz, almost there.
// running tests
After updateRecords(collection, 2468, “tracks”, “Free”), tracks should have 1999 as the first element.
After updateRecords(collection, 2548, “tracks”, “”), tracks should not be set
// tests completed

what’s your updated code?

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

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

  object[id][prop] = value;

} else if (prop === "tracks" && !object[id].hasOwnProperty(value)) {

  object[id][prop] = [value];

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


} else if (value === "") {

  delete object[id][prop];


return object;


I’m sorry @ilenia I had some problems at home. It’s the one in the last post.

and what do the tests say?

Here they are @ilenia

I’m pretty sure that the only thing that isn’t correct right now is this:


On this line, you should exchange value with "tracks".

For reference: freeCodeCamp Challenge Guide: Record Collection

1 Like

@Frakkoz Yeeesss that was it! Thank you so much for all your help! To @MrBondx and @ilenia too. But thank you lots @Frakkoz because you nailed it and you gave me the solution (and funny thing, I had written earlier what you said but there were other issues as well).
Happy coding to all

1 Like