Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
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
14 changes: 14 additions & 0 deletions InClass/Callbacks/exercise-1/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@ Update your code to make the colour change every 5 seconds to something differen
Prefer to work on a codepen? https://codepen.io/makanti/pen/abOreLg
================
*/


setTimeout(() => {
document.body.style.background = "blue"
}, 5000);

let colors = ["red", "green", "yellow", "blue", "pink"];
let index = 0;
function change() {
document.body.style.background = colors[index];
index = (index = 1) % colors.length;
}

setInterval(change, 5000);
15 changes: 15 additions & 0 deletions InClass/Callbacks/exercise-2/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,18 @@ const movies = [
// create a new movie object for your favorite movie

// create addMovies function

function display(movie) {
let list = document.getElementById("all-movies");
var entry = document.createElement('li');
entry.innerHTML = `<strong> ${movie.title} </strong> ${movie.director} <em>${movie.type}</em>`;
list.appendChild(entry);
}

function showMovies() {
movies.forEach((movie, index) => {
setTimeout(display, index * 2000, movie)
});
}

showMovies();
23 changes: 22 additions & 1 deletion mandatory/1-alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
function setAlarm() {}
function setAlarm() {
let input = document.querySelector("#alarmSet").value;
let timeRemaining = document.querySelector("#timeRemaining");



function setTimer() {
if(input > 0){
input --;
let minutes = Math.floor(input/60);
let seconds = input % 60;
timeRemaining.innerText = `Time Remaining: 0${minutes} : 0${seconds}`;

if (input === 0){
playAlarm();
}
}

}
setInterval(setTimer, 1000);
}


// DO NOT EDIT BELOW HERE

Expand Down
1 change: 1 addition & 0 deletions mandatory/2-quotegenerator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</head>
<body>
<!-- Write your HTML in here -->
<div id="quote"></div>
<script src="quotes.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions mandatory/2-quotegenerator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
let quote = document.querySelector("#quote");
let h1El = document.createElement("h1");
h1El.innerText = "Quote Generator:";
quote.appendChild(h1El);
let buttonEl = document.createElement("button");
buttonEl.innerText = "New Quote";
quote.appendChild(buttonEl);
buttonEl.addEventListener("click", () => {
let randomQuotes = quotes[Math.floor(Math.random() * quotes.length)];
let pEl = document.createElement("p");
pEl.innerText = `${randomQuotes.quote} \n Author: ${randomQuotes.author}`;
quote.appendChild(pEl);
});

// DO NOT EDIT BELOW HERE

// A function which will return one item, at
Expand Down