Profile LookUp, need an explanation

Was struggling with Profile Lookup and ended up getting the “right” answer. How could i improve?

Here is the answer i used to finish the excercise.

  // Only change code below this line
  const akiraProfile = [...contacts][0];
  // console.log(akiraProfile);
  const harryProfile = [...contacts][1];
  // console.log(harryProfile);
  const sherlockProfile = [...contacts][2];
  const kristianProfile = [...contacts][3];

  if ( prop = 'lastName' && name === kristianProfile.firstName) {
    return kristianProfile.lastName;
  if (prop = 'likes' && name === sherlockProfile.firstName) {
    return sherlockProfile.likes
  if (prop = 'likes' && name === harryProfile.firstName) {
    return harryProfile.likes
  if (name === 'Bob') {
    return 'No such contact';
  if (prop !== 'likes' || prop !== 'lastName' || prop !== 'number') {
    return 'No such property'

why are you using an assignment operator here?

You can improve by not hardcoding your solution like this

I actually didn’t notice that until you pointed it out. Some context, i was at my wits end when i wrote this.

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