Record Collection Challenge - Console.log Bug?

Hey everybody,

first of all, sorry for my bad english. I’m from Germany, so it’s not my native language, but i try my best to be understandable.

It’s not like i’m stuck at that challenge because i dont know how i could get my code to work, because i have a few ideas, but, everytime i simply try to console.log() something, it replies 8 times in my brower console.

So lets say i reset the challenge code, and i write console.log(collection[id]) in the area i am allowed to write text, i get the following answer from my brower console.

Object {album: “ABBA Gold”}
Object {album: “ABBA Gold”}
Object {album: “ABBA Gold”}
Object {album: “ABBA Gold”}
Object {album: “Slippery When Wet”, artist: “Bon Jovi”, tracks: Array[2]}
Object {artist: “Robert Palmer”, tracks: Array[0]}
Object {album: “1999”, artist: “Prince”, tracks: Array[2]}
Object {album: “Slippery When Wet”, artist: “Bon Jovi”, tracks: Array[2]}album: "Slippery When Wet"artist: "Bon Jovi"tracks: Array[2]proto: Object

… well… yeah… wtf happend? does anyone know how i can fix this? i’m using the latest Chrome browser, and if i use Fire fox i get the same result.

if i use the site repl.it, the console gives me the following output:

{ album: ‘ABBA Gold’ }

just this one line. Help would be realy realy nice <3

thanks and have a nice day everybody!

here is the code btw.

 // 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) {
      
      
      return console.log(collection[id]);
    }
    // Alter values below to test your code
    updateRecords(5439, "artist", "ABBA");

Your code is ran against several test cases and that’s why your console.log is executed several times.

but why do i get different outcomes?

Because the function is being called with different parameters. It might be easier to have your function return the value that you want to know. For example: instead of console.log(collection[id]) use return collection[id]. Then it will only return one value and display it in the black area.

1 Like

thanks that helped me and i got this challenge completed ^^

1 Like