New learner here, I'm stuck on a practice question for a course and I'm not sure what it's asking me to do here. The problem is as follows:
Write a function that takes a user object, which represents a user of the Northcoders website, and returns the value of the password key from that object.
If the user object does not contain a password key, the function should instead return undefined.
A typical user object might look like this:
{ name: 'Lucy', password: 'n0rthc0derzzz' }
Requirements are as follows:
- Returns undefined when given a user object where no password key is present - check
- Returns a password from a user object when a password key is present - unchecked
Starting code is:
function retrievePassword (user) { // Your code goes here...
So judging by //Your code goes here...
I'm not supposed to change the arguments for the function since I'm supposed to write my code below.
Any help much appreciated! Thanks in advance!