Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Sound #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
Binary file added beep.mp3.mp3
Binary file not shown.
11 changes: 7 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ let time = 0,
timerMiliseconds = 0,
timerRunning = false,
timerInterval;
let audio = new Audio("./beep.mp3.mp3");

function getTime() {
time = prompt("Enter time in minutes");
Expand Down Expand Up @@ -158,7 +159,7 @@ function timer() {
$("#timer-min").html(addTrailingZero(timerMinutes));
$("#timer-sec").html(addTrailingZero(timerSeconds));
$("#timer-ms").html(addTrailingZero(timerMiliseconds));

timeUp();
}

Expand Down Expand Up @@ -193,9 +194,11 @@ function timeUp() {
timerMiliseconds === 0
) {
stopTimer();
alert("Time's up!");

setTime();
audio.play();
setTimeout(()=>{
alert("Time's up!")
setTime();
}, 15);
}
}

Expand Down