← Back to challenges

How Many Days Until 2021?

JavaScriptHarddates

Instructions

Given a date, return how many days date is away from 2021 (end date not included). date will be in mm/dd/yyyy format.

Examples

daysUntil2021("12/28/2020") ➞ "3 days"

daysUntil2021("1/1/2020") ➞ "366 days"

daysUntil2021("2/28/2020") ➞ "308 days"

Notes

All given dates will be in the year 2020.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.