Updating doesn't work with function's parameters

Guys,

When I use this code to update an object (inside or not a function - add a property with a value) it works:

collection[5439].artist = “ABBA”;

but when I use this function, it doesn’t work. where is my mistake?

function updateRecords(id, prop, value) {
collection[id].prop = “value”;
return collection;
}
console.log(updateRecords(5439, “artist”, “ABBA”));

Thanks.

Fábio.

where you called the function ? it’s not getting inside the function

I called the function inside the console.log. outside the function. Like I posted.

i think you need to call it inside the function?

called function should end with semicolon

updateRecords(5439, “artist”, “ABBA”);

image

I think the syntax is corret.

Man, I don’t get it, call inside the function?

Now you get that
yeah now it’s correct

I used correct syntax before. It doesn’t work. I don’t get it.

I had to do this way: image

and Not this way: collection[id].prop = “value”;

I got it. Thanks everybody.