Question: Write a javascript function called getDay which can find out which day of the week a specific date was. It should return the day of

Write a javascript function called getDay which can find out which day of the week a specific date was. It should return the day of the week string.

Here are the building blocks you need to write the function: const date = new Date('2010-04-01'); var weekDays = ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; //return index between 0 and 6 console.log(date.getDay()); //look up the week day text string from the Array console.log(weekDays[date.getDay()]);

These asserts will test your function:

assert.equal(getDay('2010-04-01'), "Thursday"); assert.equal(getDay('2012-02-13'), "Monday");

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!