JSFiddle - React, Tailwind, and code Playground
by al nmeri
JavaScript
/* its a searchfunction thats supposed to search for a name. if fthat name rhymes with a property in the friends object, it should return every detail about that contact*/
var friends = {};
friends.bill = {
firstName: "Bill",
lastName: "Window",
number: "07039841657",
address: ['43', 'Ogwuagor', 'Road']
};
friends.steve = {
firstName: "Stephen",
lastName: "Work",
number: "07086994594",
address: ['Abakpa', 'Nike', 'Lake']
};
function list(friends) {
for (var steve in friends) {
console.log(steve);
}
}
function search(name) {
for (var steve in friends) {
if (friends[steve].firstName === name) {
console.log(friends[steve]);
return friends[steve];
}
}
}