Please, someone tell me what is wrong with this code?
function lookUpProfile(name, prop) {
// Only change code below this line
contacts.map((item)=>{
if(item.firstName===name){
if(item.hasOwnProperty(prop)){
return item[prop];
}
else{
return "No such property.";
}
}
})
return "No such contact.";
// Only change code above this line
}
You did pretty good but remember that they have automatic test so you need to write this:
"No such property"
"No such contact"
WITHOUT dot, .
An also you shouldn’t use .map() method for this because it returns the mapped array.
Use a regular for loop or a for...of loop. Also at this point of the curriculum you did not have seen functional programming, so try to solve all the challenges with basic JS, you will improve your solving problems skill doing that.
Your code is correct you just need to change that and you will pass it.
Use console.log() to check your code and test it will help you a lot. For example: