Freecodecamp: [Manipulating Complex Objects] Example is unsatisfactory as a guide

Created on 24 Jan 2017  路  4Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Manipulating Complex Objects has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0.

I think that it should stress the fact that you are looking at an array. This way, maybe new coders may recall that arrays need commas between... indexes, and pass the test with less effort.
Also, mentioning JSON is useless here and detracts from the exercise.

My code:

var myMusic = [
  { 
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  ]
  ]}// Add record here /*many attempts in many places including ".unshift()" and ".push()" species all because the example does not show a n-objects array making me wonder into the realms of the uncanny code.*/
];


discussing

Most helpful comment

Until I read your issue, I didn't understand what syntax the interpreter was expecting, either. The mention of JSON additionally was distracting if we are not learning/using it in the exercise. It may be common sense to people who are coming from a programming background, but with only hobbyist experience, it was unclear.

All 4 comments

@Undigon Unless I am misunderstanding your meaning — the challenge pretty clearly states, twice, that this is an object on an array.

Once in the intro:

This is an array which contains one object inside. The object has various pieces of metadata about an album. It also has a nested "formats" array. If you want to add more album records, you can do this by adding records to the top level array.

and once in the instructions:

Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.

Not sure if we can get a whole lot clearer. The only way I can see this being is clearer is by specifically stating that the object should be manually added to the array.

Although, not sure the challenge name is necessarily suitable since no object is actually being manipulated. Perhaps "Introduction to Complex Data Structures" would be more appropriate.

@Undigon I agree with @no-stack-dub-sack. If you read the text that accompanies the challenge, it mentions you are looking at an array. JSON is mentioned because of the similarities between JavaScript objects. But I can see an argument of how it could be distracting.

Until I read your issue, I didn't understand what syntax the interpreter was expecting, either. The mention of JSON additionally was distracting if we are not learning/using it in the exercise. It may be common sense to people who are coming from a programming background, but with only hobbyist experience, it was unclear.

The problem is that there is no comma after the pre-built entry (line 12 of the code). So if, like me, you're operating under the assumption that you're not to change code above the comment, you're screwed. I would suggest that the exercise already have the comma after the }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaibsharma picture vaibsharma  路  3Comments

QuincyLarson picture QuincyLarson  路  3Comments

jurijuri picture jurijuri  路  3Comments

kokushozero picture kokushozero  路  3Comments

SaintPeter picture SaintPeter  路  3Comments