← Back to challenges

Get the Date

JavaScriptHarddatesformattinglanguage_fundamentals

Instructions

Write a function that, given a date (in the format MM/DD/YYYY), returns the day of the week as a string. Each day name must be one of the following strings: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", or "Saturday".

To illustrate, the day of the week for "12/07/2016" is "Wednesday".

Examples

getDay("12/07/2016") ➞ "Wednesday"

getDay("09/04/2016") ➞ "Sunday"

getDay("12/08/2011") ➞ "Thursday"

Notes

This challenge assumes the week starts on Sunday.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Twitter Link Finder