question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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");


Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Francois-Leblanccommented, Jun 22, 2017

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!

0reactions
vedant15188commented, Jun 12, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

is it possible to not return anything from a function in python?
Functions always return something (at least None , when no return-statement was reached during execution and the end of the function is reached)....
Read more >
The Python return Statement: Usage and Best Practices
Everything in Python is an object. So, your functions can return numeric values ( int , float , and complex values), collections and...
Read more >
Object.defineProperty() - JavaScript - MDN Web Docs
This method allows a precise addition to or modification of a property on an object. Normal property addition through assignment creates ...
Read more >
Function that manipulates collection and return the same type
It isn't generally possible to return a new collection, because you don't know what the constructor expects. I.e. type(original)(new_values) ...
Read more >
Collection (Java Platform SE 8 ) - Oracle Help Center
The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs. Returns: an array...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found