question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with the description text.

See original GitHub issue

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

Instructions in description text:

For the given id in collection:

If prop does not contain the key "tracks", then update or set the value for that incomplete prop.

If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.

If prop does contain the key "tracks" and its value is non-blank, then push the value onto the end of its existing tracks array.

If value is blank, delete that prop.

Its just a sugesstion because your instructions (specially 3rd line) are confusing a lot of people . So I think you should change it . Your third line should be something like If the concerned object does not contain the key "tracks" ,then update it by creating an empty array before pushing a track to it. because you only want to update when prop contains the value key but the concerned object doesn’t have the tracks property.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
revisualizecommented, Jun 26, 2016

I agree, I have some real concerns about the verbiage used in the checkpoint: Record Collection - https://www.freecodecamp.com/challenges/record-collection

// Each album is identified by a unique id number (its key) 
// and has several properties. Not all albums have complete information.
console.log(Object.keys(collection));
console.log(Object.keys(collection["2548"]));
console.log(Object.keys(collection["2468"]));
console.log(Object.keys(collection["1245"]));
console.log(Object.keys(collection["5439"]));

// Write a function which takes an id, a property (prop), and a value.
// - Great done.
function updateRecords(id, prop, value) {
   // For the given id in collection:
      for (id in collection) {
   // If prop does not contain the key "tracks", 
   // then update or set the value for that incomplete prop.
      //? Are we talking about the parameter 'prop' that is passed
      //? into the function? Or are we talking about the Object[id] keys? 

   // If prop does not contain the key "tracks" 
   // before you update it, 
   // create an empty array before pushing a track to it.
      //? Same question.

   // If prop does contain the key "tracks" 
   // and its value is non-blank, 
   // then push the value onto the end of its existing tracks array.
         //: Based on those instuctions, I would write something like this. (Which isn't correct.)
         if (prop === Object.keys(collection[id][prop]) && collection[id][prop] === "") {
            collection[id][prop].push(value);
         }
   // If value is blank, 
   // delete that prop.
         if (value === "") {
            delete collection[id][prop];
         }
      }
   // Always return the entire collection object.
      return collection;
}

I mean if you look this over the verbiage doesn’t make sense. It may just be semantics but, for someone learning JavaScript. I’m really confused by the new instructions. The old instructions made more sense: https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Challenge-Record-Collection

// Write a function which takes:
//  an id, a property (prop), and a value.
function updateRecords(id, prop, value) {
// If value is non-blank (value !== "") 
// and prop is not "tracks" 
// then update or set the value for the prop.
    // Your code here

// If the prop is "tracks" and value is non-blank,
// push the value onto the end of the tracks array.
    // Your code here

// If value is blank, 
// delete that prop.
    // Your code here

// Always return the entire collection object.
  return collection;
}

If you look on my profile: https://www.freecodecamp.com/revisualize You can see two different ways that I solved “Record Collection” before the verbiage in the instructions was changed.

// Only change code below this line
function updateRecords(id, prop, value) {
  // If value is non-blank (value !== "") and 
  // prop is not "tracks" 
  // then update or set the value for the prop.
  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  }
  // If the prop is "tracks" and value is non-blank, 
  // push the value onto the end of the tracks array.
  else if (prop === "tracks" && value !== "") {
    if (!collection[id].hasOwnProperty(prop)) {
      collection[id][prop] = [];
    }
    collection[id][prop].push(value);
  }
  // If value is blank, 
  // delete that prop.
  else if (value === "") {
    delete collection[id][prop];
  }
  // Always return the entire collection object.
  return collection;
}

// Alter values below to test your code
updateRecords(1245, "tracks", "Addicted to Love");

/*
The fucntion could also be written like this:

function updateRecords(id, prop, value) {
  if (value !== '') {
      if (prop === 'tracks') {
          if (!collection[id].hasOwnProperty(prop)) {
            collection[id][prop] = [];
          }
          collection[id][prop].push(value);
      } else {
          collection[id][prop] = value;
      }
  } else {
    delete collection[id][prop];
  }
  return collection;
}

*/
3reactions
erictleungcommented, Jun 30, 2016

@wiseleo thanks for the feedback. I like your changes and rationale for each change. The instructions should be changed to:

You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album’s id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn’t "tracks" and value isn’t blank, update or set the value for that record album’s property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn’t have a "tracks" property, create an empty array before adding the new value to the album’s corresponding property.

If prop is "tracks" and value isn’t blank, push the value onto the end of the album’s existing tracks array.

If value is blank, delete that property from the album.

Please first read the contributing guidelines before taking care of this issue. And feel free to visit the Contributors Help chat room if you have any questions about helping. We’re there to help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem & Solution Structure in Text: Overview & Signal Words
The first signal word indicating it is a problem is "dilemmas"; the problem is the overall adoption of electric vehicles. The specific problem ......
Read more >
How to fix: Text too short: description [description]
Sign in to your Merchant Center account. Select Products on the navigation menu, then click Diagnostics. Click the Item issues tab to see...
Read more >
students' difficulties in writing descriptive text at the seventh ...
Linguistics difficulties in writing descriptive text include the aspect regarding grammatical items and vocabulary mastery. The result showed ...
Read more >
Problem and Solution, Description and Procedural/Sequence ...
Problem and Solution, Description and Procedural/Sequence ENGLISH 4 WEEK 4 Part 2 ... Grade 4 English Q1 Ep5: Identifying Various Text Types.
Read more >
AN ANALYSIS OF STUDENTS' DIFFICULTIES IN WRITING ...
While the factors that cause the students' difficulties in writing descriptive text are lack of proficiency in the text production skills, lack of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found