Can’t seem to make this one work with while loop
These criterias don’t work:
“Kristian”, “lastName” should return “Vos”
“Sherlock”, “likes” should return [“Intriguing Cases”, “Violin”]
“Harry”,“likes” should return an array
these do:
“Bob”, “number” should return “No such contact”
“Akira”, “address” should return “No such property”
function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
var target;
while (i<contacts.length) {
target = contacts[i];
if (target.firstName === firstName) {
if (target.hasOwnProperty(prop)==1){
return target[prop];
}else{
return "No such property";
}
}else{
return "No such contact";
}
i++;
}
// Only change code above this line
}
any help is appreciated