Contact List exercise of javascript track


#1

Couldn't understand why this code is not running ?

var friends = {
bill:{
firstName:"Bill",
lastName:"Gates",
number:"something",
address:['One Microsoft Way','Redmond','WA','98052']
},
steve:{
firstName:"Steve",
lastName:"Joe",
number:"Steve's number",
address:['One Microsoft Way','Redmond','WA','98052']
}
};

var search = funtion(name)
{
for(var key in friends)
{
if (friends[key].firstName === name)
{
console.log(friends[key]);
return friends[key];
}
}

};

It's returning SyntaxError: Illegal return statement error.
While this bit of code is running just fine.
I couldn't understand the difference between them for they all look the same ?

var friends = {
bill:{
firstName:"Bill",
lastName:"Gates",
number:"something",
address:['One Microsoft Way','Redmond','WA','98052']
},
steve:{
firstName:"Steve",
lastName:"Joe",
number:"Steve's number",
address:['One Microsoft Way','Redmond','WA','98052']
}
};

var search = function(name) {
for(var key in friends) {
if(friends[key].firstName === name) {
console.log(friends[key]);
return friends[key];
}
}
};

Any suggestions ??


#2

Here function has typo - missing "c".