Skip to content

Commit 4b26922

Browse files
committed
add exercise 8
1 parent 0ca8dfa commit 4b26922

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

exercices/8/8.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>dayjs practice</title>
5+
</head>
6+
<body>
7+
8+
9+
<script type="module" src="8.js"></script>
10+
</body>
11+
</html>
12+
13+
14+

exercices/8/8.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import dayjs from 'https://cdn.jsdelivr.net/npm/dayjs/+esm';
2+
import isSatSun from './weekend.js';
3+
4+
5+
// 5 days after today, in the format of 'month' 'day of month'
6+
console.log(dayjs().add(5, 'days').format('MMMM dddd'))
7+
8+
// 1 month after today, in the format of 'month' 'day of month'
9+
console.log(dayjs().add(1, 'months').format('MMMM dddd'))
10+
11+
// 1 month before today, in the format of 'month' 'day of month'
12+
console.log(dayjs().subtract(1, 'months').format('MMMM dddd'))
13+
14+
// today, in the format of 'day of week'
15+
console.log(dayjs().format('dddd'))
16+
17+
18+
19+
20+
// will output true if day is either sunday or saturday, function is imported
21+
console.log(isSatSun(dayjs().format('dddd')))
22+
console.log(isSatSun(dayjs().subtract(1, 'days').format('dddd')))
23+
console.log(isSatSun(dayjs().subtract(3, 'days').format('dddd')))
24+
console.log(isSatSun(dayjs().add(3, 'days').format('dddd')))

exercices/8/weekend.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check if today is weekend day
2+
function isWeekend(date){
3+
if (date === 'Sunday' || date === 'Saturday'){
4+
return true;
5+
} else {
6+
return false;
7+
}
8+
};
9+
10+
export default isWeekend;

0 commit comments

Comments
 (0)