<h4 dir="auto">Challenge Name</h4>

<p dir="auto">Record Collection</p>
<h4 dir="auto">Issue Description</h4>

<p dir="auto">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.</p>
<p dir="auto">try :</p>
<h4 dir="auto">Invalid Code</h4>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Setup
var collection = {
    &quot;2548&quot;: {
      &quot;album&quot;: &quot;Slippery When Wet&quot;,
      &quot;artist&quot;: &quot;Bon Jovi&quot;,
      &quot;tracks&quot;: [ 
        &quot;Let It Rock&quot;, 
        &quot;You Give Love a Bad Name&quot; 
      ]
    },
    &quot;2468&quot;: {
      &quot;album&quot;: &quot;1999&quot;,
      &quot;artist&quot;: &quot;Prince&quot;,
      &quot;tracks&quot;: [ 
        &quot;1999&quot;, 
        &quot;Little Red Corvette&quot; 
      ]
    },
    &quot;1245&quot;: {
      &quot;artist&quot;: &quot;Robert Palmer&quot;,
      &quot;tracks&quot;: [ ]
    },
    &quot;5439&quot;: {
      &quot;album&quot;: &quot;ABBA Gold&quot;
    }
};
// 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 !== &quot;tracks&quot;)
  {
    collection[id].tracks = [];
    collection[id][prop] = value;
  } 
  else if (value)
     collection[id].tracks.push(value);
  if (value === &quot;&quot;)
    delete collection[id][prop];
  return collection;
}

// Alter values below to test your code

updateRecords(5439, &quot;tracks&quot;, &quot;Take a Chance on Me&quot;);"><pre class="notranslate"><span class="pl-c">// Setup</span>
<span class="pl-k">var</span> <span class="pl-s1">collection</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-s">"2548"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"album"</span>: <span class="pl-s">"Slippery When Wet"</span><span class="pl-kos">,</span>
      <span class="pl-s">"artist"</span>: <span class="pl-s">"Bon Jovi"</span><span class="pl-kos">,</span>
      <span class="pl-s">"tracks"</span>: <span class="pl-kos">[</span> 
        <span class="pl-s">"Let It Rock"</span><span class="pl-kos">,</span> 
        <span class="pl-s">"You Give Love a Bad Name"</span> 
      <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s">"2468"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"album"</span>: <span class="pl-s">"1999"</span><span class="pl-kos">,</span>
      <span class="pl-s">"artist"</span>: <span class="pl-s">"Prince"</span><span class="pl-kos">,</span>
      <span class="pl-s">"tracks"</span>: <span class="pl-kos">[</span> 
        <span class="pl-s">"1999"</span><span class="pl-kos">,</span> 
        <span class="pl-s">"Little Red Corvette"</span> 
      <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s">"1245"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"artist"</span>: <span class="pl-s">"Robert Palmer"</span><span class="pl-kos">,</span>
      <span class="pl-s">"tracks"</span>: <span class="pl-kos">[</span> <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s">"5439"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"album"</span>: <span class="pl-s">"ABBA Gold"</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-c">// Keep a copy of the collection for tests</span>
<span class="pl-k">var</span> <span class="pl-s1">collectionCopy</span> <span class="pl-c1">=</span> <span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">parse</span><span class="pl-kos">(</span><span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">collection</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// Only change code below this line</span>
<span class="pl-k">function</span> <span class="pl-en">updateRecords</span><span class="pl-kos">(</span><span class="pl-s1">id</span><span class="pl-kos">,</span> <span class="pl-s1">prop</span><span class="pl-kos">,</span> <span class="pl-s1">value</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

  <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">prop</span> <span class="pl-c1">!==</span> <span class="pl-s">"tracks"</span><span class="pl-kos">)</span>
  <span class="pl-kos">{</span>
    <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
    <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s1">prop</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">value</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span> 
  <span class="pl-k">else</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span>
     <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">value</span> <span class="pl-c1">===</span> <span class="pl-s">""</span><span class="pl-kos">)</span>
    <span class="pl-k">delete</span> <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s1">prop</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-s1">collection</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">// Alter values below to test your code</span>

<span class="pl-en">updateRecords</span><span class="pl-kos">(</span><span class="pl-c1">5439</span><span class="pl-kos">,</span> <span class="pl-s">"tracks"</span><span class="pl-kos">,</span> <span class="pl-s">"Take a Chance on Me"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Change the calling function, by one of these and it will work and valid :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="updateRecords(5439, &quot;artist&quot;, &quot;ABBA&quot;);
updateRecords(2548, &quot;artist&quot;, &quot;&quot;);
updateRecords(1245, &quot;tracks&quot;, &quot;Addicted to Love&quot;);
updateRecords(2468, &quot;tracks&quot;, &quot;Free&quot;);
updateRecords(2548, &quot;tracks&quot;, &quot;&quot;);"><pre class="notranslate"><code class="notranslate">updateRecords(5439, "artist", "ABBA");
updateRecords(2548, "artist", "");
updateRecords(1245, "tracks", "Addicted to Love");
updateRecords(2468, "tracks", "Free");
updateRecords(2548, "tracks", "");
</code></pre></div>
<p dir="auto">The solution to the first test :</p>
<h4 dir="auto">Valid Code</h4>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Setup
var collection = {
    &quot;2548&quot;: {
      &quot;album&quot;: &quot;Slippery When Wet&quot;,
      &quot;artist&quot;: &quot;Bon Jovi&quot;,
      &quot;tracks&quot;: [ 
        &quot;Let It Rock&quot;, 
        &quot;You Give Love a Bad Name&quot; 
      ]
    },
    &quot;2468&quot;: {
      &quot;album&quot;: &quot;1999&quot;,
      &quot;artist&quot;: &quot;Prince&quot;,
      &quot;tracks&quot;: [ 
        &quot;1999&quot;, 
        &quot;Little Red Corvette&quot; 
      ]
    },
    &quot;1245&quot;: {
      &quot;artist&quot;: &quot;Robert Palmer&quot;,
      &quot;tracks&quot;: [ ]
    },
    &quot;5439&quot;: {
      &quot;album&quot;: &quot;ABBA Gold&quot;
    }
};
// 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 !== &quot;tracks&quot;)
  {
    collection[id].tracks = [];
    collection[id][prop] = value;
  } 
  else if (value)
  {
     if (collection[id].hasOwnProperty(&quot;tracks&quot;) === false)
        collection[id].tracks = [];
     collection[id].tracks.push(value);
  }
  if (value === &quot;&quot;)
    delete collection[id][prop];
  return collection;
}

// Alter values below to test your code

updateRecords(5439, &quot;tracks&quot;, &quot;Take a Chance on Me&quot;);"><pre class="notranslate"><span class="pl-c">// Setup</span>
<span class="pl-k">var</span> <span class="pl-s1">collection</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-s">"2548"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"album"</span>: <span class="pl-s">"Slippery When Wet"</span><span class="pl-kos">,</span>
      <span class="pl-s">"artist"</span>: <span class="pl-s">"Bon Jovi"</span><span class="pl-kos">,</span>
      <span class="pl-s">"tracks"</span>: <span class="pl-kos">[</span> 
        <span class="pl-s">"Let It Rock"</span><span class="pl-kos">,</span> 
        <span class="pl-s">"You Give Love a Bad Name"</span> 
      <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s">"2468"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"album"</span>: <span class="pl-s">"1999"</span><span class="pl-kos">,</span>
      <span class="pl-s">"artist"</span>: <span class="pl-s">"Prince"</span><span class="pl-kos">,</span>
      <span class="pl-s">"tracks"</span>: <span class="pl-kos">[</span> 
        <span class="pl-s">"1999"</span><span class="pl-kos">,</span> 
        <span class="pl-s">"Little Red Corvette"</span> 
      <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s">"1245"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"artist"</span>: <span class="pl-s">"Robert Palmer"</span><span class="pl-kos">,</span>
      <span class="pl-s">"tracks"</span>: <span class="pl-kos">[</span> <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s">"5439"</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"album"</span>: <span class="pl-s">"ABBA Gold"</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-c">// Keep a copy of the collection for tests</span>
<span class="pl-k">var</span> <span class="pl-s1">collectionCopy</span> <span class="pl-c1">=</span> <span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">parse</span><span class="pl-kos">(</span><span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">collection</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// Only change code below this line</span>
<span class="pl-k">function</span> <span class="pl-en">updateRecords</span><span class="pl-kos">(</span><span class="pl-s1">id</span><span class="pl-kos">,</span> <span class="pl-s1">prop</span><span class="pl-kos">,</span> <span class="pl-s1">value</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

  <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">prop</span> <span class="pl-c1">!==</span> <span class="pl-s">"tracks"</span><span class="pl-kos">)</span>
  <span class="pl-kos">{</span>
    <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
    <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s1">prop</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">value</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span> 
  <span class="pl-k">else</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span>
  <span class="pl-kos">{</span>
     <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">hasOwnProperty</span><span class="pl-kos">(</span><span class="pl-s">"tracks"</span><span class="pl-kos">)</span> <span class="pl-c1">===</span> <span class="pl-c1">false</span><span class="pl-kos">)</span>
        <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
     <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">value</span> <span class="pl-c1">===</span> <span class="pl-s">""</span><span class="pl-kos">)</span>
    <span class="pl-k">delete</span> <span class="pl-s1">collection</span><span class="pl-kos">[</span><span class="pl-s1">id</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s1">prop</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-s1">collection</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">// Alter values below to test your code</span>

<span class="pl-en">updateRecords</span><span class="pl-kos">(</span><span class="pl-c1">5439</span><span class="pl-kos">,</span> <span class="pl-s">"tracks"</span><span class="pl-kos">,</span> <span class="pl-s">"Take a Chance on Me"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">I simply check if tracks exist, otherwise I init.</p>
<h3 dir="auto">Possible Cause</h3>
<ul dir="auto">
<li>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.</li>
<li>Or maybe the case described is insufficient :</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Origine : 
If prop does not contain the key &quot;tracks&quot; before you update it, create an empty array before pushing a track to it."><pre class="notranslate"><code class="notranslate">Origine : 
If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.
</code></pre></div>
<p dir="auto">If prop contain tracks but tracks isn't init, create an empty array ?</p>
<ul dir="auto">
<li>Maybe a strict mode.</li>
</ul>
<h4 dir="auto">Browser Information</h4>

<p dir="auto">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.</p>
<ul dir="auto">
<li>Browser Name, Version: Mozilla 47.0</li>
<li>Operating System: Windows 7</li>
<li>Mobile, Desktop, or Tablet:</li>
</ul>
<p dir="auto">Hope my information are relevant.<br>
Sorry for my bad english, have a nice day.</p>
<p dir="auto">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!</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/10459779/10044696/f2e3a110-61ca-11e5-98f3-0100007b0452.png"><img src="https://cloud.githubusercontent.com/assets/10459779/10044696/f2e3a110-61ca-11e5-98f3-0100007b0452.png" alt="fcc-issue" style="max-width: 100%;"></a></p>