Freecodecamp: I can't modify the function to return anything other than collection...

Created on 1 Jun 2017  Â·  7Comments  Â·  Source: freeCodeCamp/freeCodeCamp

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

My 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 exists function --
  console.log("falsy");
  return false;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");


help wanted bug

Most helpful comment

Have the same issue.

Change 'return collection;' for 'return "I am a duck";' and see the 'problem'.

So far in all the FCC challenges, the "return" in the main function shows the return value in the console. This challenge is different however as it always returns the collection regardless of what you put in it. It's as if the return inside updateRecords is completely ignored for some reason.

I'm used to modify the return value in examples to debug, so I always play around with it. This prevents from doing that unfortunately.

@vedant15188 you are right about the goal of this challenge, however it is inconsistent with the way all the previous challenges showed return value in the console.

For the sake of consistency, I hope this will be looked into. Thanks!

All 7 comments

Hi there,

Could you please describe what you are having trouble with? The function updateRecords is returning false in your code snippet, and you will need to alter it to return the right type. Could you post a little bit more on this?

Sorry, yes, I altered the function to try to have it return false ( or anything) but in the console log it always just returned the entire "collection" array. I eventually passed the exercise, but it wasn't like other exercises in that the output in the console didn't do what I told it to... other than returning the collection array. It was a different behavior than other exercises and was difficult because debugging my code was a bit harder because I couldn't output just a single thing to the console to make sure that line of code was working. Does this explain it better?.

Could you copy and past the code that you were expecting to pass but having trouble with? Maybe there's something we can explain better here in the instructions.

Could someone tell me how to resolve this issue? I just wrote
return id;
and thats it in my updateRecords function and all it keeps returning is the collections object.

I didn't get any resolution other than making the function to modify the
collection and solving the challenge. It always returns the collection for
some reason, but it does show modifications to it.

On Thu, Jun 8, 2017 at 6:57 PM Vedant Kashyap notifications@github.com
wrote:

Could someone tell me how to resolve this issue? I just wrote
return id;
and thats it in my updateRecords function and all it keeps returning is
the collections object.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/freeCodeCamp/freeCodeCamp/issues/15153#issuecomment-307146222,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AYFARrd-MDAMwcrbLk9zMAgmG3cwnyLfks5sCBnOgaJpZM4NsoLF
.

>

Ummm according to me the function will always return collection...

The main aim of the challenge is to modify the copy of the Collection and then equate it back to the collections object...
You can solve the challenge that way and the changes will be reflected on the collections #object too... It works for me.

Have the same issue.

Change 'return collection;' for 'return "I am a duck";' and see the 'problem'.

So far in all the FCC challenges, the "return" in the main function shows the return value in the console. This challenge is different however as it always returns the collection regardless of what you put in it. It's as if the return inside updateRecords is completely ignored for some reason.

I'm used to modify the return value in examples to debug, so I always play around with it. This prevents from doing that unfortunately.

@vedant15188 you are right about the goal of this challenge, however it is inconsistent with the way all the previous challenges showed return value in the console.

For the sake of consistency, I hope this will be looked into. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jurijuri picture jurijuri  Â·  3Comments

QuincyLarson picture QuincyLarson  Â·  3Comments

kokushozero picture kokushozero  Â·  3Comments

bagrounds picture bagrounds  Â·  3Comments

DaphnisM picture DaphnisM  Â·  3Comments