Record collection vs fcc editor problem


Hi all, I developed the code for this challenge using, tested it against every test. It is now working in
I copied the code into the fcc editor (bonfire?) and then my troubles began:

The code no longer passes the tests where the property should be deleted because the input value argument is empty.

  • After updateRecords(2548, “artist”, “”), artist should not be set
  • After updateRecords(2548, “tracks”, “”), tracks should not be set

It doesn’t make sense to me…

  • I have checked the delete stmt in my code: it returns true
  • I have console checked the relevant collection entry just before the return, and the properties have indeed been deleted. Still, the tests fail.
  • I also tried it in jsfiddle - and there it works as required !!!

Here’s my code:

// Keep a copy of the collection for tests
var colCopy = JSON.parse(JSON.stringify(collection));
// Only change code below this line
function updateRecords(id, prop, value) {
  if (colCopy[id][prop] !== undefined)  // property exists
  function update() {
    if (value === "") {
      delete colCopy[id][prop]; // <---- THIS RETURNS TRUE
    } else {
      if (prop === "tracks")
        colCopy[id][prop] = value;  

  function create() {
    if (value !== "") {
      if (prop === "tracks") {
        colCopy[id][prop] = [];
      } else {
        colCopy[id][prop] = value;
  if (id == 2548) console.log(id, prop, value, colCopy[id]); // <---- THIS SHOWS THE PROPERTIES ARE GONE
  return colCopy;
updateRecords(5439, "artist", "ABBA");

Can anyone help me find out what I am doing wrong here?
Thanks in advance.


Your code works fine, but you changed collectionCopy to colCopy. Apparently the tests check collectionCopy and will therefore fail. The only thing you have to do, is change everything from colCopy to collectionCopy.


Many thanks. I was tearing my hair out :confounded:


I use also for my FCC code challenges. I don’t think the tests check how you go about a problem or what you call your variables. The FCC tests check against expected output.

I use console.log() for each test, example below. So far, I haven’t had any troubles passing the challenges with that approach.

FCC Sum All Numbers in a Range

//FCC Sum All Numbers in a Range
function sumAll(arr) {
  var total = 0;
  var max = Math.max.apply(null, arr);
  var min = Math.min.apply(null, arr);
  for(var i = min; i <= max; i++){
    total +=i;

  return total;

console.log("\n1: should return a number \n" + sumAll([1, 4]));
console.log("\n2: should return 10 \n" + sumAll([1, 4]));
console.log("\n3: should return 10 \n" + sumAll([4, 1]));
console.log("\n4: should return 45 \n" + sumAll([5, 10]));
console.log("\n5: should return 45 \n" + sumAll([10, 5]));


They won’t care about locally scoped variables in the functions, but in this case the changed variable name is global, and the comments explicitly stated that it’ll be used for the tests.

Not only that, but it’s supposed to be a carbon copy of the original in its initial state, so only the original (collection) should be modified.


Yes, that’s what I meant. Only the internal workings of a method do not effect the tests. If the method was called Foo, and you changed it to Bar, the tests would fail.