I Am Stuck Guys! Please Help Me!

Hello, fellow programmers. I have been learning Javascript on Freecodecamp for quite some time now and so far I am at 82%. I got really stuck at this level and I don’t know how to pass the test. Please, help me with the solution to the code below:

Record Collection

You are given an object literal representing a part of your musical album collection. Each album has a unique id number as its key and several other properties. Not all albums have complete information.

You start with an updateRecords function that takes an object literal, records , containing the musical album collection, an id , a prop (like artist or tracks ), and a value . Complete the function using the rules below to modify the object passed to the function.

  • Your function must always return the entire record collection object.
  • If prop isn’t tracks and value isn’t an empty string, update or set that album’s prop to value .
  • If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it.
  • If prop is tracks and value isn’t an empty string, add value to the end of the album’s existing tracks array.
  • If value is an empty string, delete the given prop property from the album.

Note: A copy of the recordCollection object is used for the tests.

// Setup
var recordCollection = {
2548: {
  albumTitle: 'Slippery When Wet',
  artist: 'Bon Jovi',
  tracks: ['Let It Rock', 'You Give Love a Bad Name']
2468: {
  albumTitle: '1999',
  artist: 'Prince',
  tracks: ['1999', 'Little Red Corvette']
1245: {
  artist: 'Robert Palmer',
  tracks: []
5439: {
  albumTitle: 'ABBA Gold'

// Only change code below this line
function updateRecords(records, id, prop, value) {
if (records) {
  return records[recordCollection];
else {
return records;


updateRecords(recordCollection, 5439, 'artist', 'ABBA');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

Challenge: Record Collection

Link to the challenge:

I don’t see where you have implemented any of the requested logic? Is there a part of the instructions you don’t understand?

How do I solve the challenge? It’s a challenge on Freecodecamp and no video to help

I’m not going to hand you the solution. Giving you a solution to copy makes it harder for you to solve future challenges.

So, is there a part of the instructions you don’t understand?

1 Like

Okay, I understand your point. Let me cool down and look at it very well. But, any guide from you can help. I don’t even know how to start solving this

try to make it one line at a time, if you find that one specific line doesn’t make sense ask for help about it, explaining what you get and what you need help with


Do you understand the requirement? Do you know how to do this?

1 Like

I think you can return the “entire collection” using else statement. Like so>>>

     collection[id][prop] = [value];
   return *collection*;

Why hide that inside of an else statement? You need to always return the entire record collection.

Hmmm! Okay. Let me keep learning

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 (’).

Oh, sorry. I didn’t know. Thanks for the head up

what’s collection? you don’t have such variable defined anywhere in your code

I think the instruction is to create a collection. See the instruction below:

You aren’t creating a collection. You are updating the records object, which holds the collection.

Oh, I think I have seen the code on starkoverflow. It works but I want to get it sink into my brain. Lol!

solving it on your own is an awesome way to get it to sink into your brain

1 Like

Yes sir. I will keep trying. Thanks for you time. I really appreciate

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