Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions