There is no lastName
or number
or likes
argument.
There are exactly two arguments always provided in the exact same order. Never more. Never less. Never any different order.
lookUpProfile(name, prop)
The name
argument always refers to the firstName
{
"firstName": "Akira", // 'name' refers to this part of the object
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
The prop
argument always refers to the key for some property that you are looking for
{
"firstName": "Akira",
// 'prop' could contain "lastName", "number", "likes", "address", "potatoe", "someOtherKeyThatIsNotPresent"
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
It is your job to make the code find the contact that has a "firstName"
that matches the given name
.
If you find the contact with the matching name, then you need to determine if the contact has the property with the key prop
.
If you find a macthing contact with a matching property, return the value of that property.
If name
does not correspond to any contacts then return the string No such contact
.
If prop
does not correspond to any valid properties of a contact found to match name
then return the string No such property
.
You should be able to test your code with the sample outputs:
lookUpProfile("Kristian", "lastName");// should return the string `Vos`
lookUpProfile("Sherlock", "likes"); // should return `["Intriguing Cases", "Violin"]`
lookUpProfile("Harry", "likes"); // should return an array
lookUpProfile("Bob", "number"); // should return the string `No such contact`
lookUpProfile("Bob", "potato"); // should return the string `No such contact`
lookUpProfile("Akira", "address"); // should return the string `No such property`