Skip to content

Commit 7d18e63

Browse files
author
JorvanW
committed
Update code for "alarmclock.js"
1 parent 1461d83 commit 7d18e63

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎Sprint-3/alarmclock/alarmclock.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
function setAlarm() {}
1+
function setAlarm() {
2+
// Get the input element
3+
const alarmSetInput = document.getElementById("alarmSet");
4+
5+
// Get the number of seconds
6+
const seconds = Number(alarmSetInput.value);
7+
8+
// Validate input
9+
if (seconds <= 0 || isNaN(seconds)) {
10+
alert("Please enter a valid number.");
11+
return;
12+
}
13+
14+
// Wait the specified number of seconds
15+
setTimeout(() => {
16+
playAlarm()
17+
}, seconds * 1000);
18+
}
219

320
// DO NOT EDIT BELOW HERE
421

0 commit comments

Comments
 (0)