Profile Lookup - JavaScript Algorithms and Data Structures

Please, someone tell me what is wrong with this code?

function lookUpProfile(name, prop) {
  // Only change code below this line>{
          return item[prop];
          return "No such property.";
  return "No such contact.";
  // Only change code above this line
1 Like

Hi @Aravin7 and welcome!!

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. :smile:

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:

console.log({ property: contact[prop] });
console.log(lookUpProfile("Akira", "likes"));

Good work and happy coding!!!

1 Like

Thanks a lot @carlosvisator

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.