# Please don't know what am doing, I need help understanding this

**URL:** <https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 21, 2021, 4:06pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787 "2021-08-21T16:06:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![malcom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/malcom/32/229819_2.png) [@malcom](https://forum.freecodecamp.org/u/malcom)\
**Post date:** [August 21, 2021, 4:06pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/1 "2021-08-21T16:06:41Z")

</div>

**Tell us what’s happening:**  
please i’ve been going through the basic javascript tutorial and am on topic Record Collection and i was given a task to code:

* * *

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.

* * *

**and below is the code i was given to alter . Please i need assistance. thanks**

```
  **Your code so far**

```

```js

// 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) {
return records;
}

updateRecords(recordCollection, 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/92.0.4515.159 Safari/537.36`

**Challenge:** Record Collection

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection)**
>
> Learn to Code — For Free

* * *

This is a screenshot of one of the attempts i’ve made. please am new to coding that’s why its bad:

 ![Learn Basic JavaScript_ Record Collection _ freeCodeCamp.org - Google Chrome 8_21_2021 4_47_10 PM](https://global.discourse-cdn.com/freecodecamp/original/3X/3/4/34957f9d57f0305c30d67b7441e8503ff9350bff.png)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [August 21, 2021, 4:10pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/2 "2021-08-21T16:10:57Z")

</div>

Hello there.

Do you have a question?

If so, please edit your post to include it in the **Tell us what’s happening** section.

Learning to describe problems is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [August 21, 2021, 4:36pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/3 "2021-08-21T16:36:01Z")

</div>

It looks like now you’ve copied the instructions to the challenge into your post.

What part of the instructions are confusing? What have you tried so far?

---

<div class="post-metadata">

**Author:** ![malcom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/malcom/32/229819_2.png) [@malcom](https://forum.freecodecamp.org/u/malcom)\
**Post date:** [August 21, 2021, 4:36pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/4 "2021-08-21T16:36:39Z")

</div>

thanks for your response. I’ve updated my question as Guided.

---

<div class="post-metadata">

**Author:** ![malcom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/malcom/32/229819_2.png) [@malcom](https://forum.freecodecamp.org/u/malcom)\
**Post date:** [August 21, 2021, 4:44pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/5 "2021-08-21T16:44:07Z")

</div>

I’ve tried to analyze the question but to no avail.

this is a screen shot of one of my bad attempts:

 ![Learn Basic JavaScript_ Record Collection _ freeCodeCamp.org - Google Chrome 8_21_2021 4_47_10 PM](https://global.discourse-cdn.com/freecodecamp/original/3X/3/4/34957f9d57f0305c30d67b7441e8503ff9350bff.png)

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [August 21, 2021, 4:47pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/6 "2021-08-21T16:47:04Z")

</div>

Screenshots are almost impossible to debug. Please provide your actual code.

One big problem I’m seeing is that you are incorrectly using dot notation. You cannot use dot notation with a variable holding the name of the property you want.

---

<div class="post-metadata">

**Author:** ![malcom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/malcom/32/229819_2.png) [@malcom](https://forum.freecodecamp.org/u/malcom)\
**Post date:** [August 21, 2021, 5:16pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/7 "2021-08-21T17:16:14Z")

</div>

```auto
// 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 (prop == records.id.track && value != ""){

    records.id.prop = value;

  }

  if(prop == tracks && id.albumTitle.includes(tracks)==false){

    var empty =[""];

    empty.push(value);

    records.id.push(empty);

  }

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

    records.id.tracks.push(value);

  }

  return records;

}

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

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [August 21, 2021, 5:23pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/8 "2021-08-21T17:23:21Z")

</div>

I see bad syntax, so it’s not easy to say how’s your logic

> [@malcom](#):
>
> ` records.id.prop`

first, you need to review how to access object properties with variables

> [@malcom](#):
>
> `prop == records.id.track `

`prop` is a variable containing a string, you need to compare it to a string

> [@malcom](#):
>
> `prop == tracks`

same as above

> [@malcom](#):
>
> `id.albumTitle.includes(tracks)`

`includes` is an array method, `id.albumTitle` is not an array

> [@malcom](#):
>
> ` var empty =[""];`

that’s not an empty array

> [@malcom](#):
>
> `records.id.push(empty);`

`records.id` is not an array so you can’t use `push` to it

---

<div class="post-metadata">

**Author:** ![malcom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/malcom/32/229819_2.png) [@malcom](https://forum.freecodecamp.org/u/malcom)\
**Post date:** [August 21, 2021, 5:36pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/9 "2021-08-21T17:36:36Z")

</div>

yeah omg you’re right, thanks. I’ll re-evaluate it and get back to you if am still messing it up. Thanks again.

---

<div class="post-metadata">

**Author:** ![malcom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/malcom/32/229819_2.png) [@malcom](https://forum.freecodecamp.org/u/malcom)\
**Post date:** [August 21, 2021, 5:47pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/10 "2021-08-21T17:47:13Z")

</div>

> //thanks guys i got extra assistance, so the code below works for anyone with similar problem. Setup:

Mod Edit: SOLUTION REDACTED

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [August 21, 2021, 6:09pm UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/11 "2021-08-21T18:09:40Z")

</div>

It is great that you solved the challenge, but we are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.  
If you post a full passing solution to a challenge and have questions about it, please surround it with `[spoiler]` and `[/spoiler]` tags on the line above and below your solution code.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [February 20, 2022, 6:10am UTC](https://forum.freecodecamp.org/t/please-dont-know-what-am-doing-i-need-help-understanding-this/474787/12 "2022-02-20T06:10:41Z")

</div>

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