We Made a Friend SOLVED


Is there something that you would like to ask?

That error message seems to be suggesting to add some more contacts, what are your thoughts around that? If you want to know something, you’ll have to ask for it.

@haxor789 any thoughts I’m stuck its say i only have two contacts in the array

this exercise is complete yet the code has an error i added the add function and called add below

Could you post copyable and formatted code, please?

Also what is the exercise this is referring to?
So far there should be 3 objects in contacts.
Refreshed the page?

That doesn’t explain what you want to know, what you expect or what you have tried so far. It’s like screaming that you have a giant lime green rubber duck. Great. Not sure why I need to know about that though.

What do you want to know?

my code won’t run are you able to point out what its missing

we made friend / building an address book
function add(firstName,lastName,email,phoneNumber){
firstName :firstName,
lastName : lastName,
email : email,
phoneNumber : phoneNumber
var bob = {
firstName: “Bob”,
lastName: “Jones”,
phoneNumber: “(650) 777-7777”,
email: "bob.jones@example.com"

var mary = {
firstName: “Mary”,
lastName: “Johnson”,
phoneNumber: “(650) 888-8888”,
email: "mary.johnson@example.com"

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++) {
function search(lastName){
contactsLength = contacts.length;
for(var i= 0; i < contactsLength; i++) {
if (contacts[i].lastName == lastName){

/Create a search function
then call it passing “Jones”

Isn’t your error message already doing that?

If not, in what way isn’t it?

thank you i solved it was a miss spelled word

1 Like

Just got to the same result. In case you experience something like this extensively use console.log. console.log the contacts array before after and during the adding and everywhere you think something should change until you get it. :slightly_smiling:

PS: Also pretty interesting how arrays handle that square bracket notation for non-number indices.

i used the same code but i get this

Oops, try again. It looks like there are still only two items in the contacts array.