-
Notifications
You must be signed in to change notification settings - Fork 18
/
03.js
33 lines (28 loc) · 760 Bytes
/
03.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Check if one date is earlier than another
// Write a function that takes as argument an object with the properties a and b, each containing a date instance
// It should return true if date a is earlier than date b
// It should return false otherwise
function myFunction({ a, b }) {
return +a < +b;
// return a.getTime() < b.getTime();
// AUTHOR'S:
// return a < b
}
console.log(
myFunction({
a: new Date("2000/01/01 08:00:00"),
b: new Date("2000/01/01 08:45:00"),
})
); // true
console.log(
myFunction({
a: new Date("2000/01/01 08:45:00"),
b: new Date("2000/01/01 08:00:00"),
})
); // false
console.log(
myFunction({
a: new Date("2000/01/01 08:00:00"),
b: new Date("2000/01/01 08:00:00"),
})
); // false