Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
function setAlarm() {}

let myTimer;
function setAlarm() {
// fist need to get the input from the id=alarmset
let setTimeSeconds = document.getElementById("alarmSet").value;
console.log(setTimeSeconds);
myTimer = setInterval(() => {
const minutes = Math.trunc(setTimeSeconds / 60);
const seconds = setTimeSeconds % 60;
console.log(minutes);
// then update time remaining whith the value of alarm set
const upDate = document.getElementById("timeRemaining");
// Time Remaining: 00:00
upDate.innerHTML = `Time Remaining: ${minutes
.toString()
.padStart(2, "0")}: ${seconds.toString().padStart(2, "0")}`;
// Check if we get to zero
if (setTimeSeconds <= 0) {
playAlarm();
clearInterval(myTimer);
}
// need tomake the functon counting donw seconds by one until get 00:00
setTimeSeconds = setTimeSeconds - 1;
}, 1000);
}
// DO NOT EDIT BELOW HERE

var audio = new Audio("alarmsound.mp3");
Expand Down
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>Alarm clock app</title>
</head>
<body>
<div class="centre">
Expand Down
Loading