Profile Lookup Challenge JS

Profile Lookup Challenge JS
0

#1
function lookUpProfile(firstName, prop){
// Only change code below this line
var myArr=[];
for(var i=0;i<=contacts.length-1;i++){
  myArr.push(contacts[i].firstName);}
  if(myArr.includes(firstName)){
  var a=myArr.indexOf(firstName);
   if(contacts[a].hasOwnProperty(prop)){
    console.log(contacts[a][prop]);
  }else{
    console.log("No such property");
  } 
  
}else {
  console.log("No such contact");
}
}
// Only change code above this line

  

// Change these values to test your function
lookUpProfile("Akira", "likes");

My code works perfectly with Chrome console. I’ve tried every scenario and it works but challenge doesn’t execute my code. The console section is blank. Now i cant pass the challenge. Can anybody help?


#2

You are not returning anything.


#3

It appears to be working, because you are using console.log statements to display the results, but you should be using return statements. The FCC tests are calling the lookUpProfile function and expect results to be returned.


#4

i changed and passed it.thanks