Hardtime learning Javascript

Hey everyone,

I started learning javascript last week and am having a bit of a hard time figuring out the logic. I didn’t really understand how collection[id][prop] = value works. Also couldn’t figure out on my own how to put the code together and had to watch the video. Once I watch it all makes sense, but in multiple exercises like this I had the same issue.

My main question is, is it normal to struggle with this in the begging? Are there any tips for wrapping your head around how this works? I started studying js with another course and only switched to this one when I realized I was having a hard time understanding - put now I seem to still be having a hard time.


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

// Only change code below this line
function updateRecords(id, prop, value) {
if (value === ""){
delete collection[id][prop];
}else if (prop === 'tracks'){
collection[id][prop] = collection[id][prop] || [];
collection[id][prop].push(value)
} else {
collection[id][prop] = value
}

return collection;
}

updateRecords(5439, "artist", "ABBA");

Your browser information:

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

Challenge: Record Collection

Link to the challenge:

I didn’t really start fully understanding Javascript until after completing the certification challenges and some of the Front End Libraries lessons.

2 Likes

It’s definitely normal to struggle. Learning your first programming language is hard stuff.

I would not suggest looking at the solution (from videos, the hints, or searching online) for multiple challenges in a row. Being able to follow someone else’s logic is a different skill than being able to arrive at a solution yourself. I suggest coming here to the forum where we can help you “connect the dots” yourself.

4 Likes