Skip to content
Advertisement

Basic Profile Lookup always returning no contact found

So I’ve recently begun learning Javascript using the tutorials on freecodecamp and there’s this challenge I’ve been stuck on for a few hours now.

The function always returns ‘No contact found’ and I don’t understand why. If someone were to explain it to me and correct my code, I’d be grateful.

JavaScript

Advertisement

Answer

Try this

Explanation

  1. Typo error change like this contacts[i]['firstName'] instead of contacts[i][firstName].you are missing to match the keyname of obj.for your way its calling like

    contacts[i][Akira] == false statement so only it always go else statement

  2. Do the object key call method with obj[key] instead of obj.key .Beacuse all are varible not with direct name of the key

  3. second one hasownproperty(varible) .you are not mention which word to check with that object

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement