Okay, I have taken a tutorial to create an unnamed object in an array using a function Given an array called contacts in which two named objects exist:
function add(firstName, lastName, phoneNumber, email) {
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email
};
}
add("Buddy", "King", "312-555-5555", "[email protected]");
that adds the unnamed object. But what do I do if I want to give the new object a name? I would like to use the first parameter )"Buddy" as the object name, so convert the string to ???