Question: Expertise needed in Javascript - The exercise - Given the customerData object below, write a function greetCustomer that takes in a similar object and a
Expertise needed in Javascript -
The exercise - Given the customerData object below, write a function greetCustomer that takes in a similar object and a name. Given that name, return a greeting based on how many times that person has visited your establishment.
Essentially, you will check the name given to your function against the names in the object given to your function. For example: const customerData = { 'Joe': { visits: 1 }, 'Carol': { visits: 2 }, 'Howard': { visits: 3 }, 'Carrie': { visits: 4 } }
// If the customer is not present in customerData: greetCustomer(customerData, 'Terrance')
// 'Welcome! Is this your first time?' // If the customer has visited only once ('visits' value is 1): greetCustomer(customerData, 'Joe')
// 'Welcome back, Joe! We're glad you liked us the first time!' // If the customer is a repeat customer: ('visits' value is greater than 1): greetCustomer(customerData, 'Carol')
// 'Welcome back, Carol! It's good to see again
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
