Basic JavaScript - Record Collection

My post is less about needing help and more about understanding the expectations of the course, or more specifically, the Record Collection task.

I feel as though I was understanding everything decently up until this point. I was, however, completely stumped with this one. I looked at the hint and eventually the solutions and now fully understand, but I’m wondering…is the expectation such that complete beginners like myself should have understood how to do this Record Collection task by this point with no help, or is it expected that most beginners would need to check the hints to get through it?

Your code so far

// Setup
const 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 (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];
  }
  
  return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

It is expected that learners will check hints and ask questions on various challenges.

It is not expected or recommended for learners to look at the answers before solving any challenge.

Writing code to solve a complex task is hard and takes a bunch of practice. Unfortunately, reading code and writing code are two separate skills. You should practice both, but you should only practice reading other people’s answers after you have practiced writing your own answer.

Thanks Jeremy. The biggest confusion for me was maybe the lack of context. I mean, looking at the below, I couldn’t understand how the code had logic built into it so that “prop” would automatically associate with albumTitle/artist/tracks and “id” with the numbers listed. I did assume that they would be connected somehow, but it wasn’t obvious and kind of crashed my brain right from the start.

In the end, if I had just accepted that they were connected, without any guidance telling me otherwise, I would have made a little more progress before needing to get help. All that aside, this is a really cool training system and I’m happy to have found it :slight_smile:

There isn’t anything in the function signature requiring this - you have to put that logic in yourself.

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

The specific values are determined by the function call, but the challenge is not requiring that you make sure the inputs actually match what they are called. You get to assume that all function calls will be ‘valid’.

I think it’s a very well designed problem. It is hard because it requires thinking and problem solving instead of how many of the previous challenges are more focused on syntax replication. All required concepts are covered in previous challenges.

(post deleted by author)

You cannot avoid doing research as a programmer.

This problem doesn’t involve research though. Literally every required concept was covered on previous steps. This problem requires you to stop and think about how to use the syntax you were taught, which is harder than repeating the syntax like in previous problems.

Just replicating somebody else’s logic doesn’t help you build problem solving skills in this domain, and those skills are critical.

Programming is what it is called when you use JavaScript. If you learn JavaScript, you are a programmer.

You can be all those things without being a paid professional. All levels of programmers need problem solving and research.

Some people choose to look at answers, but you aren’t forced to look at the answers in any way. It is better to ask questions, as copying the answer doesn’t really teach you anything.

It is unfortunately impossible to write the challenges such that nobody ever needs help.

This is hard because, like I said, it is one of the first challenges actually expecting you to combine knowledge and do actual problem solving. It is a really hard transition to make.

Sure. Learn to take critique. I deleted all my posts because an argument is not helpful to new people. To summarise my issues with this problem:

  1. It is not worded clearly enough.
  2. It requests you use concepts that haven’t been used in this way without giving clarity.
  3. It doesn’t offer adequate hints, understandable for someone new to javascript.

I have had no issue with any problem before or after, and I’m clearly not alone. Take from it what you will. I really don’t care if nobody reviews this question, but it would be nice for other newcomers if you would. Good luck.

I don’t agree with your critique. That doesn’t mean I didn’t hear it - it means I disagree with it.

  1. The wording is accurate. Turning accurate wording describing a problem into a code solution is just hard.

  2. The concepts all work in the same way as taught before.

  3. The hints section on the forum I haven’t looked at recently. Maybe it should be updated.

Like I said, this is the first problem that starts requiring important synthesis of concepts. That’s why it is hard - synthesis and problem solving are new skills being introduced on this step.

im so confused with this problem. i dont even have code to start anything. im confused on starting it and how to tackle it. If anyone can help me out to understand id really appreciate it. like this problem has caused me to cry and want to throw shit for the past 3 days. i want to learn this so bad.

If you have a question about a specific challenge as it relates to your written code for that challenge, and you’ve tried to solve it at least 3 times so far and still need some help, just click the Ask for Help button located on the challenge (it looks like a question mark).
This button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

Hi! This step presented me a hard time. I still don’t understand fully how the object (recordCollection) is asociated with “records”, i’ve failed it misserably until changed all my recordCollection[id][prop] to records[id][prop]. Can someone explain it for me? Thanks

The object ‘recordCollection’ is passed to the function as a function parameter called ‘records’. So, within the function, every time you use ‘records’ it will refer (in this case) to ‘recordCollection’. Of course, the point of doing this is that the code is reusable and could be used to update any other similarly-structured object which is passed to the same function.

If you’re struggling with this challenge, please create your own help topic with your code and a description of exactly what you’re struggling with.

1 Like

If you have a question about a specific challenge as it relates to your written code for that challenge, and you’ve tried to solve it at least 3 times so far and still need some help, just click the Ask for Help button located on the challenge (it looks like a question mark).
This button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.