Contact List


#1

Ive been struggleing with this for 2 hours..anybody help needed.

https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#

There was a problem with your syntax.

var friends = new Object();

friends.bill = new Object();
friends.steve = new Object();
friends.Regan = new Object();
friends.Alex = new Object();
friends.Jesse = new Object();
friends.Colin = new Object();
var list = function (friends) {
for (var firstname in friends);
    console.log(firstname);
}
var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ['One Microsoft Way','Redmond','WA','98052']
    }
};
var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ['One Microsoft Way','Redmond','WA','98052']
    }
var search = function(name){
for(var y in friends){
if(friends[y].firstName === name){
console.log(friends[y]);
return friends[y];
}
};

#2

Which exercise are you on?


#3

7.Search for a friend


#5

You don't need to add the semicolon in the line above. I think that is what is throwing the syntax error car friends = ...

Regards,
Barry Allen


#6

still the same message im getting here barry


#7

Why have you declared the object friends twice @devninja93146?


#8

I think what you should do is declare a few friends in friends using

friends.name = {
    firstName : "blah",
    //etc...
}

comment out the two explicit declarations of the friends object and then submit your code.

Regards,
Barry Allen


#9

I dont know why this is not working.
https://www.codecademy.com/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661#
3. ...And the Good!
~~~~~
var number = 20;
for (var i =0, i.length< 21, i++)
console.log ("that's it")
if (number / 3) {
console.log("fizz")
}
if else (number / 5) {
console.log ("buzz")
}
else {
console.log("FizzBuzz")
};
~~~~~


#10

@devninja93146, first off all, in your first for loop, you have set the condition as i.length < 20. This is unnecessary because i isn't an array or string object, you can simply put i < 21.

Secondly, "Fizz" and "Buzz" should be capitalised, and you should also remove the ( I suspected frustrated) console.log("that's it") from your code.

Thirdly, your if statement logic is incorrect. You should use the modulo (%) operator if you want to check divisibility of a number by another one.

And lastly, think about where your FizzBuzz is located. FizzBuzz should only log to the console when it is divisible by both 3 and 5. But in your case it says it everytime a number in NOT divisible by three or five. You need to check whether the number is divisible by five by nesting an if loop inside your if (number / 3) (fix this btw)

When you resolve all of this, your code will work fine...

Regards,
Barry Allen


#11

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