-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
72 lines (60 loc) · 1.6 KB
/
test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
let car = [
{
model: "van1",
rsvpStartDate: "2022-10-10T00:00:00.000Z",
rsvpEndDate: "2022-10-12T00:00:00.000Z",
rsvpDates: "",
},
{
model: "van2",
rsvpStartDate: "2022-10-12T00:00:00.000Z",
rsvpEndDate: "2022-10-13T00:00:00.000Z",
},
{
model: "van3",
rsvpStartDate: "2022-10-11T00:00:00.000Z",
rsvpEndDate: "2022-10-14T00:00:00.000Z",
},
];
const userDates = ["2022-10-10", "2022-10-13"];
function getDatesInRange(startDate, endDate) {
const date = new Date(startDate.getTime());
const dates = [];
while (date <= endDate) {
dates.push(new Date(date));
date.setDate(date.getDate() + 1);
}
return dates;
}
const str = new Date(userDates[0]);
const ed = new Date(userDates[1]);
let userDatesRange = getDatesInRange(str, ed);
// userDatesRange.map((date, i) => {
// car.map(({ model, rsvpStartDate, rsvpEndDate }) => {
// date == rsvpStartDate
// ? console.log("here", model)
// : console.log("not here");
// });
// });
console.log(userDatesRange[0]);
console.log(car[0].rsvpStartDate >= userDatesRange[0]);
userDatesRange.map((date) => {
console.log(date);
console.log(date == car[0].rsvpStartDate);
});
// console.log(userDatesRange);
// car.map(({ model, rsvpStartDate, rsvpEndDate }, idx) => {
// console.log(
// rsvpStartDate == userDatesRange
// ? "good" + rsvpStartDate
// : "bad" + rsvpStartDate
// );
// });
//map
// car.map(
// ({ model, rsvpStartDate, rsvpEndDate }) => {
// userDatesRange.indexOf(userDates[0]) === rsvpStartDate
// ? console.log(model)
// : "badrequest";
// }
// );