In: Computer Science
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts a Date object dateStr and returns a string that is the day of the week in English form (i.e. “Sunday”, “Monday”, etc.). Test your function by creating a date object that is a significant date to you (such as your birthday) and passing that date object to your function. Test your function at least twice with two different dates. Submit the dayOfWeek.js file to the server. It should include your function code and your two tests.
/* Below is your required function. I have also included the output just to show it's working*/
const dayOfWeek = dateStr => {
var days =
['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var day = days[ dateStr.getDay() ];
return day;
};