Freecodecamp: Manipulating Complex Objects - question

Created on 27 Jan 2017  路  8Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Manipulating Complex Objects has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];

  {
    "artist": "Daft Punk",
    "title": "Homework",
    "release_year": 1997,
    "formats": [ 
      "CD", 
      "Cassette", 
      "LP" ],
    "gold": true
  }
];

Hello everyone, I been trying to pass this section for about two days, and I asked for help on github but no one responds. I been manipulating the code multiple times, and I even used the same example in the instructions but no luck passing the section if you could please explain in detail what I did wrong or what is wrong with the code thank yo in advance.

Most helpful comment

@RomingArt, if you copied @HasanFaraaz's solution exactly, the code will not pass because there is an issue with his comment. That code is technically incorrect, while his solution is ok. As far as I can see, there is still not a bug with this challenge. Did my explanation not help any? Read the explanation so you understand what the issue is and remove everything from the editor and paste this in:
```js
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}, // <-- comma needed here, also, you pasted the object in the wrong place
{
"artist":"Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [ "CS", "8T",
"LP" ],
"gold": true
}
];

All 8 comments

Hi @RomingArt

The issue tracker is for reporting bugs only. If this is a request for help with a challenge, please use the help chat room or try looking through the forum for help with a specific challenge.

If this is the case, please close this issue.

Happy Coding.

--
_Automated response by Var.CI_ :robot:

@RomingArt Sorry that you were not getting the help you were looking for - were you in the gitter chat rooms?

The key to this challenge is in the instructions here:

Note
You will need to place a comma after every object in the array, unless it is the last object in the array.

Also, you should take a look at how many square brackets you have ( [ ] ) - if you have an odd number, something is up. All brackets, curly or square, need to have a matching opening or closing bracket. In your example, you have an unnecessary closing bracket, and you are adding your object in the wrong place:

image

The array that the challenge is referring to begins and ends where I've pointed out in the above image. You need to add your new object as a second element on that array. So where that comment is, it literally wants you to put it directly where it is, not under it. Where you originally had it, is actually _outside_ the myMusic array. And don't forget the note from the instructions that I pointed out up top! 馃槃 Good luck and I hope this helps. I'm closing this issue, but feel free to respond here anyway.

As it seems like you realize, this is mostly for reporting bugs, so try your best to seek help elsewhere first, but in situations like this, if you were unable to get help, you did the right thing!

@RomingArt

The code should be:-

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },//A comma was missing in the code

  {
    "artist":"Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ "CS", "8T", 
      "LP" ],
    "gold": true
  }
];

I think it was bug where the "comma" was missed after the first object.

Hello everyone, thank you for your feedback, but I am still not able to pass this section, and I tried the code of @HasanFaraaz but it still does not let me pass.

@RomingArt, if you copied @HasanFaraaz's solution exactly, the code will not pass because there is an issue with his comment. That code is technically incorrect, while his solution is ok. As far as I can see, there is still not a bug with this challenge. Did my explanation not help any? Read the explanation so you understand what the issue is and remove everything from the editor and paste this in:
```js
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}, // <-- comma needed here, also, you pasted the object in the wrong place
{
"artist":"Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [ "CS", "8T",
"LP" ],
"gold": true
}
];

@RomingArt I have edited the code now, i had put a comment which I thought would be ignored(the comment was made bold & italic) now it should be fine. @no-stack-dub-sack

@HasanFaraaz Within code blocks on github, markdown does not work, so the bold and italic didn't come through, instead just the literal markdown:

_**ignored markdown**_

@RomingArt hoping this gives you a good idea, please note, your original solution was not just missing a comma, please see my original post as well. I'm going to go ahead and close this now - if for some reason you are still unable to pass the challenge, please reopen this issue and provide additional detail. Thanks and good luck!

try this

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}, //note the comer here
// the code below adds another album to the obj

{
"artist": "Paco de Lucia",
"title": "Live in America",
"release_year": 1992,
"formats" : [ "CS", "8T", "LP" ]

         }

];

Was this page helpful?
0 / 5 - 0 ratings