Question: IN JAVASCRIPT PLEASE The notablePeople associative array contains a list of some notable individuals and birthdays. Ex: notablePeople[Elvis Presley] contains Elvis' birthday, which is Jan

IN JAVASCRIPT PLEASE

The notablePeople associative array contains a list of some notable individuals and birthdays. Ex: notablePeople["Elvis Presley"] contains Elvis' birthday, which is Jan 8, 1935.

  1. The first for-in loop displays each person's name and birthday, but the format of the birthday is too wordy. Change the output format to MM/DD/YYYY. Ex: Elvis Presley: 1/8/1935.

  2. Add a for-in loop to display each person born before Sonya Sotomayor and the rounded number of days difference in birth day. Ex: Elvis Presley was born 7108 days before Sonya Sotomayor Franklin D. Roosevelt was born 26443 days before Sonya Sotomayor ...

    • The getDifferenceInDays() utility function is provided in the code below. When passed a time difference in milliseconds, the function returns the rounded number of days difference. Ex: getDifferenceInDays(person1Date.getTime() - person2Date.getTime())

  3. Add a for-in loop to display each person born after Sonya Sotomayor and the rounded number of days difference in birth day. Ex: Elon Musk was born 6212 days after Sonya Sotomayor Steve Jobs was born 244 days after Sonya Sotomayor ...

____

const notablePeople = { "Elvis Presley": new Date(1935, 0, 8), "Sonya Sotomayor": new Date(1954, 5, 25), "Franklin D. Roosevelt": new Date(1882, 0, 30), "Elon Musk": new Date(1971, 5, 28), "Roger Staubach": new Date(1942, 1, 5), "Steve Jobs": new Date(1955, 1, 24), "Albert Einstein": new Date(1879, 2, 14), "Isaac Asimov": new Date(1919, 9, 4), "Jada Pinkett Smith": new Date(1971, 8, 18), "Grace Hopper": new Date(1906, 11, 9) };

// Display all names and birthdays for (let person in notablePeople) { console.log(person + ": " + notablePeople[person]); }

// Utility function to compute the rounded number of days difference from a // time difference in milliseconds function getDifferenceInDays(timeDifferenceMilliseconds) { timeDifferenceMilliseconds = Math.abs(timeDifferenceMilliseconds); let daysDifference = timeDifferenceMilliseconds / (1000 * 60 * 60 * 24); // Return the difference rounded to the nearest whole day return Math.round(daysDifference); }

// Blank line before next section console.log("");

// Your solution here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!