Day.js isSame() method lab

Medium
3
59.1% Acceptance

In this lab, you will explore and practice the isSame() method from the Day.js library. isSame() is a helpful method that allows you to compare two Day.js objects and determine if they are the same day, week, month, year, etc., depending on the unit of time being compared.

You will be tasked with creating a compareDates() function that returns the result of the comparison between two Day.js objects using the isSame() method based on the given unit of time (day, week, month, or year). You will also have to properly import the Day.js library using ESM syntax and handle edge cases. The comparison will use the Day.js isSame(origin: string, target: string, unit?: unit) method. Read more about it here.

Day.js library installation:

To install Day.js in the lab environment, run the following command in the terminal:

yarn add dayjs