Issue 1:
Challenge Name

Record Collection

Issue Description

If I test by hand updateRecords(5439, "tracks", "Take a Chance on Me"); it wont work, otherwise any other test will work and valid challenge.

try :

Invalid Code

// 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"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if(prop !== "tracks")
{
collection[id].tracks = [];
collection[id][prop] = value;
}
else if (value)
collection[id].tracks.push(value);
if (value === "")
delete collection[id][prop];
return collection;
}

// Alter values below to test your code

updateRecords(5439, "tracks", "Take a Chance on Me");

Change the calling function, by one of these and it will work and valid :

updateRecords(5439, "artist", "ABBA");
updateRecords(2548, "artist", "");
updateRecords(1245, "tracks", "Addicted to Love");
updateRecords(2468, "tracks", "Free");
updateRecords(2548, "tracks", "");

The solution to the first test :

Valid Code

// 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"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if(prop !== "tracks")
{
collection[id].tracks = [];
collection[id][prop] = value;
}
else if (value)
{
if (collection[id].hasOwnProperty("tracks") === false)
collection[id].tracks = [];
collection[id].tracks.push(value);
}
if (value === "")
delete collection[id][prop];
return collection;
}

// Alter values below to test your code

updateRecords(5439, "tracks", "Take a Chance on Me");

I simply check if tracks exist, otherwise I init.

Possible Cause

It's maybe during unit-test, tracks is initialized before the test updateRecords(5439, "tracks", "Take a Chance on Me"); I dunno how unit-test work on js.

Or maybe the case described is insufficient :

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

If prop contain tracks but tracks isn't init, create an empty array ?

Maybe a strict mode.

Browser Information

In fact is not only me, someone on glitter called my help for this challenge which I already solved and I noticed this test was weird.

Browser Name, Version: Mozilla 47.0

Operating System: Windows 7

Mobile, Desktop, or Tablet:

Hope my information are relevant.

Sorry for my bad english, have a nice day.

Issue 2:
I think it would be better if only the most recent version of a project is shown on one's profile page. Let the discussion begin!