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
Binary file added .DS_Store
Binary file not shown.
Binary file added InClass/.DS_Store
Binary file not shown.
Binary file added InClass/Callbacks/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions InClass/Callbacks/exercise-1/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@ 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
================
*/

// task 1 - change background colour

setTimeout(function () {
document.body.style.backgroundColor = "#111";
}, 5000);

// task 2

setInterval(() => {
let differentColours = Math.floor(Math.random() * 10000).toString(16);
document.body.style.backgroundColor = `#${differentColours}`;
}, 5000);
30 changes: 30 additions & 0 deletions InClass/Callbacks/exercise-2/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@ const movies = [

// create showMovies function

function showMovies(movies) {
const moviesDiv = document.getElementById("all-movies");
movies.map((movie) => {
const movieParagraph = document.createElement("p");
moviesDiv.appendChild(movieParagraph);
const movieNumber = document.getElementById("movies-number");
movieNumber.innerText = movies.length;
movieParagraph.innerText = `${movie.title} directed by ${movie.director}`;
movieParagraph.style.backgroundColor = "#ffe6ff";
});
}

// create a new movie object for your favorite movie

const myMovie = {
title: "Roma",
director: "Alfonso Cuaron",
type: "Historical",
haveWatched: true,
};

// create addMovies function

// function addMovies(movie, callback) {
// setTimeout(function () {
// movies.push(movie);
// callback();
// }, 2000);
// }

// addMovies(showMovies, myMovie);
// console.log(movies);
showMovies(movies);
22 changes: 12 additions & 10 deletions InClass/DOM-practice/main.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
console.log("Testing JS file loaded!")
console.log("Testing JS file loaded!");

// Task 1

// Without changing any of the HTML or CSS, update the <section> tags so that they have white backgrounds.
const section = document.getElementsByTagName("section");
// console.log(section);





Array.from(section).forEach((el) => {
el.style.backgroundColor = "#fff";
});

// Task 2

// Without changing any of the HTML or CSS, update the images on the page so that they are all centered.

const images = document.querySelectorAll("img");
images.forEach((img) => {
img.style.display = "block";
img.style.marginLeft = "auto";
img.style.marginRight = "auto";
});
// Hint: look at the CSS to see if there are any classes already written which you can use.






// Task 3

// Google the date of birth and death of each of the people on the page. Without changing any of the HTML or CSS, add this in a paragraph to the end of their <section>.
Binary file added mandatory/.DS_Store
Binary file not shown.
27 changes: 26 additions & 1 deletion mandatory/1-alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
function setAlarm() {}
function setAlarm() {
let alarmSet = document.getElementById("alarmSet").value;
const timeLeft = document.getElementById("timeRemaining");

const isInterval = setInterval(() => {
const minutes = Math.floor(alarmSet / 60)
.toString()
.padStart(2, "0");
const seconds = (alarmSet % 60).toString().padStart(2, "0");
timeLeft.innerText = `Time Remaining: ${minutes}:${seconds}`;
if (alarmSet === 0) {
clearInterval(isInterval);
playAlarm();
} else {
alarmSet--;
console.log(alarmSet);
}

const alarmSound = alarmPlaying(() => {
const playButton = document.getElementById("button");
if (alarmSet === 0) {
alarmPlaying(audio.play);
}
});
}, 1000);
}

// DO NOT EDIT BELOW HERE

Expand Down
6 changes: 6 additions & 0 deletions mandatory/2-quotegenerator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Random Quote of The Day</h1>
<div id="quote">
<p class="sentence"></p>
<p class="author"></p>
<button id="newQuote" type="button">Press for a new quote!</button>
</div>
<!-- Write your HTML in here -->
<script src="quotes.js"></script>
</body>
Expand Down
19 changes: 16 additions & 3 deletions mandatory/2-quotegenerator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// pickFromArray(coloursArray) //maybe returns "#F38630"
//
// You DO NOT need to understand how this function works.
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}
// function pickFromArray(choices) {
// return choices[Math.floor(Math.random() * choices.length)];
// }

// A list of quotes you can use in your app.
// Feel free to edit them, and to add your own favourites.
Expand Down Expand Up @@ -490,3 +490,16 @@ const quotes = [
author: "Zig Ziglar",
},
];

const quoteButton = document.getElementById("author");
quoteButton.addEventListener("click", pickQuote);

function pickQuote() {
let randomNum = Math.floor(Math.random() * quotes.length);
const quoteDiv = (document.getElementById("quote").innerHTML =
quotes[randomNum]);
}

// pickQuote(quotes);

//console.log(pickQuote(quotes));