-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path4.js
More file actions
17 lines (11 loc) · 632 Bytes
/
4.js
File metadata and controls
17 lines (11 loc) · 632 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//const twelveHourClockTime = "20:53";
//const twentyFourHourClockTime = "08:53";
//variable names can't start with a number
// the times are in the wrong places ie:-20:53 is not a twelve hour time and as they are const they cant be directly changed
let twelveHourClockTime = "20:53";
let twelthHour = twelveHourClockTime.substring(0, twelveHourClockTime.length -3);
if (twelthHour >12) {twelthHour = twelthHour - 12};
let twelthMinutes = twelveHourClockTime.substring(2, twelveHourClockTime.length)
let twentyFourHourClockTime = "08:53";
console.log(`${twelthHour}${twelthMinutes}`);
console.log(twentyFourHourClockTime);