Hello,
I was stuck on Profile Lookup task, I googled solutions and all the results I found suggested nested if statements. Here is an example of the solution:
function lookUp( firstName, prop ){ for( var i = 0; i < contacts.length; i++ ){ if( firstName == contacts[i].firstName ) { if( contacts[i].hasOwnProperty( prop ) ) { return contacts[i][prop]; } else { return "No such property"; } } } return "No such contact"; }
But I don’t remember that nested if statements were discussed in any of the lessons. And I don’t know how they work. Can anyone suggest if I just missed this FreeCodeCamp lesson or explain how nested if statements work? I don’t want to simply copy this solution without understanding what it does.
Thank you!