I've been stuck on this problem for awhile, and after various attepts, I decided it was time to ask for some help.
Here's the question: Create a function called changeEmail that takes in a user object and a newEmail string. Replace the user's current email address (assigned to the email property) with the newEmail string, then return the updated user object.
Here's my code
var user = {
name: "John Doe",
email: "johndoe@gmail.com"
};
function changeEmail(param1) {
param1 = param1.email.replace("johndoe", "newjohndoe");
user.email = param1;
return user;
}
changeEmail(user);
console.log(user);