Skip to content

Commit cd6bb60

Browse files
committed
Create 03. Time + 15 Minutes.js
1 parent 27f6410 commit cd6bb60

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function timeAdd15Minutes(input) {
2+
// Time + 15 Minutes
3+
4+
let h = Number(input[0]);
5+
let m = Number(input[1]);
6+
7+
let time = h * 60 + m + 15;
8+
9+
let calcH = Math.floor(time / 60);
10+
let calcM = time % 60;
11+
12+
if (calcH > 23) {
13+
calcH = 0;
14+
}
15+
16+
if (calcM < 10) {
17+
console.log(`${calcH}:0${calcM}`);
18+
} else {
19+
console.log(`${calcH}:${calcM}`);
20+
}
21+
22+
}

0 commit comments

Comments
 (0)