Skip to content
Closed
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
32 changes: 31 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
function setAlarm() {}
function setAlarm() {
let timer;

const input = document.getElementById("alarmSet").value;
let timeLeft = Number(input);

updateDisplay(timeLeft);

clearInterval(timer);

timer = setInterval(() => {
timeLeft--;

updateDisplay(timeLeft);

if (timeLeft <= 0) {
clearInterval(timer);
playAlarm();
document.body.style.backgroundColor = "red";
}
}, 1000);
}

function updateDisplay(secondsLeft) {
const heading = document.getElementById("timeRemaining");

const minutes = Math.floor(secondsLeft / 60);
const seconds = secondsLeft % 60;

heading.innerText = `Time Remaining: ${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
}

// DO NOT EDIT BELOW HERE

Expand Down
13 changes: 13 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,16 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote

const quoteElement = document.getElementById("quote");
const authorElement = document.getElementById("author");

function displayQuote() {
const randomQuote = pickFromArray(quotes);
quoteElement.textContent = randomQuote.quote;
authorElement.textContent = randomQuote.author;
}
displayQuote();
const button = document.getElementById("new-quote");

button.addEventListener("click", displayQuote);
Loading