Finding that special someone >>> HELP ME


var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: ""

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: ""

var contacts = [bob, mary];

function printPerson(person) {
console.log(person.firstName + " " + person.lastName);

function list() {
var contactsLength = contacts.length;
for (var i = 0; i < contactsLength; i++) {

/*Create a search function
then call it passing "Jones"*/
var search = function(lastName){
var contactsLength = contacts.length;
for(var i = 0; i < contacts.Length; i++){
if(lastName === contacts[i].lastName){



Because you used for loop but you need for in:

for(var prop in contacts){
  if(contacts[prop].lastName === lastName){

From MDN:

The statement iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.


Can i give a dislike?

From the instructions

3. Create a for loop that runs through all of the items in the array. For this step, the code for search is identical to that of list

And i think a for .. in and the for statements are both loops

Look at this two lines

var contactsLength = contacts.length;
for(var i = 0; i < contacts.Length; i++) // contactsLength or contacts.length with a small l  :)


Of course, you can. This is my mistake, because I thought it's:

Of course,, for are both loops. I didn't check what instruction says :(((


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