diff --git a/Week-3/.old/InClass/A-promises/exercise.js b/Week-3/.old/InClass/A-promises/exercise.js
index c71d86e..62977ca 100644
--- a/Week-3/.old/InClass/A-promises/exercise.js
+++ b/Week-3/.old/InClass/A-promises/exercise.js
@@ -14,9 +14,17 @@
Promise"
*/
function exercise1() {
- var promise1 = resolvedPromise()
+ var promise1 = resolvedPromise();
+ return promise1;
+
}
+exercise1().then(values => {
+ let result = document.getElementById("exercise1");
+ result.textContent = values;
+ return;
+});
+
/*
EXERCISE 2
=======
@@ -28,8 +36,14 @@ function exercise1() {
*/
function exercise2() {
var promise2 = rejectedPromise()
+ return promise2;
}
-
+exercise2().then().catch(values => {
+ let result = document.getElementById("exercise2");
+ result.textContent = values;
+ console.log(result);
+ return;
+});
/*
EXERCISE 3
=======
@@ -40,8 +54,14 @@ function exercise2() {
EXPECTED RESULT: The #exercise3 element has textContent = "A Longer Promise"
*/
function exercise3() {
- var promise3 = delayedPromise()
+ var promise3 = delayedPromise();
+ return promise3;
}
+exercise3().then(values => {
+ let result = document.getElementById("exercise3");
+ result.textContent = values;
+ return;
+});
/*
EXERCISE 4
@@ -55,9 +75,14 @@ function exercise3() {
YOUR NAME"
*/
function exercise4() {
- var promise4 = concatPromise()
+ var promise4 = concatPromise();
+ return promise4;
}
-
+exercise4().then(values => {
+ let result = document.getElementById("exercise4");
+ result.textContent = values.concat("Adebola");
+ return;
+});
/*
EXERCISE 5 (Stretch Goal)
=======
@@ -70,10 +95,19 @@ function exercise4() {
EXPECTED RESULT: The #exercise5 element has textContent = "Hello Promises!"
*/
-
+let myPromise = new Promise(function(resolve){
+ resolve("Hello Promises!");
+})
function exercise5() {
+ let res = myPromise
+ return res;
// Write your implementation here
}
+exercise5().then(values => {
+ let result = document.getElementById("exercise5");
+ result.textContent = values;
+ return;
+});
/*
EXERCISE 6 (Stretch Goal)
@@ -88,9 +122,20 @@ function exercise5() {
EXPECTED RESULT: The #exercise6 element has textContent = "Something went
wrong!"
*/
+
+let justPromised = new Promise(function(reject){
+ reject("Something went wrong!");
+})
function exercise6() {
+ let worstExpectation = justPromised;
+ return worstExpectation;
// Write your implementation here
}
+exercise6().then(values => {
+ let result = document.getElementById("exercise6");
+ result.textContent = values;
+ return;
+});
//
diff --git a/Week-3/.old/InClass/B-callbacks/exercise.js b/Week-3/.old/InClass/B-callbacks/exercise.js
index 3ba78e8..539598a 100644
--- a/Week-3/.old/InClass/B-callbacks/exercise.js
+++ b/Week-3/.old/InClass/B-callbacks/exercise.js
@@ -17,6 +17,8 @@
document.querySelector('#button1').addEventListener('click', exercise1)
function exercise1() {
+ let exercise1 = document.getElementById("exercise1");
+ exercise1.textContent = "Adebola";
// Write your implementation here
}
@@ -37,6 +39,8 @@ function exercise1() {
functionThatCallsBack(exercise2)
function exercise2(result) {
+ let text = document.getElementById("exercise2");
+ text.textContent = "Hello from the function caller";
// Write your implementation here
}
@@ -57,11 +61,13 @@ function exercise2(result) {
*/
function exercise3(callback) {
+ callback("Hello from the callback");
// Write your implementation here
// Write your explanation here
+ // This callback is already a defined function and it is now used as a parameter
+ // in exercise3 function and also called in it
}
-
//
// -------------------------------------
//
diff --git a/Week-3/.old/InClass/C-fetch/exercise.js b/Week-3/.old/InClass/C-fetch/exercise.js
index fb3a39c..2e86fb1 100644
--- a/Week-3/.old/InClass/C-fetch/exercise.js
+++ b/Week-3/.old/InClass/C-fetch/exercise.js
@@ -17,10 +17,16 @@ Open index.html in your browser. Every time you refresh the page,
a different greeting should be displayed in the box.
*/
-fetch('*** Write the API address here ***')
+fetch('https://codeyourfuture.herokuapp.com/api/greetings')
.then(function(response) {
return response.text();
})
.then(function(greeting) {
+ let greet = document.getElementById("greeting-text")
+ console.log(greeting);
+ greet.innerHTML = greeting;
+ return;
+
// Write the code to display the greeting text here
- });
\ No newline at end of file
+ });
+
\ No newline at end of file
diff --git a/Week-3/.old/InClass/D-remote-clipboard/exercise.js b/Week-3/.old/InClass/D-remote-clipboard/exercise.js
index d2d83f5..633d4c5 100644
--- a/Week-3/.old/InClass/D-remote-clipboard/exercise.js
+++ b/Week-3/.old/InClass/D-remote-clipboard/exercise.js
@@ -23,7 +23,7 @@ Also, for GET request, you can use the url directly in your browser address bar
var clipboardTitle = "CHANGE ME";
var clipboardText = "CHANGE ME";
var requestBody = { title: clipboardTitle, text: clipboardText };
-
+var url = `https://codeyourfuture.herokuapp.com/api/clipboard?title=myClipboardId`;
var postRequestParameters = {
body: JSON.stringify(requestBody),
method: 'POST',
@@ -32,12 +32,17 @@ var postRequestParameters = {
}
};
-fetch(/* Write the API address here */, postRequestParameters);
+fetch(url, postRequestParameters);
// Task 2: Load an existing clipboard
// Add your code below
-fetch(/* ... */).then(function(response) {
+fetch(url).then(function(response) {
return response.text();
-}).then(/* ... */);
+}).then(function(data){
+ let myData = document.getElementById("greeting-text");
+ console.log(data);
+ myData.innerText = data;
+ return;
+});
diff --git a/Week-3/.old/InClass/E-webchat/exercise-1.js b/Week-3/.old/InClass/E-webchat/exercise-1.js
index 0e86590..821dcb0 100644
--- a/Week-3/.old/InClass/E-webchat/exercise-1.js
+++ b/Week-3/.old/InClass/E-webchat/exercise-1.js
@@ -34,4 +34,13 @@ When you open index.html in your browser, it should display the existing message
*/
-// Write your code here
\ No newline at end of file
+// Write your code here
+let url = `https://codeyourfuture.herokuapp.com/api/messages`;
+fetch(url).then(function(response) {
+ return response.text();
+}).then(function(message){
+ let myMessage = document.getElementById("message-list");
+ console.log(message);
+ myMessage.innerText = message;
+ return;
+})
\ No newline at end of file
diff --git a/Week-3/.old/InClass/E-webchat/exercise-2.js b/Week-3/.old/InClass/E-webchat/exercise-2.js
index f8a0d6f..5df2799 100644
--- a/Week-3/.old/InClass/E-webchat/exercise-2.js
+++ b/Week-3/.old/InClass/E-webchat/exercise-2.js
@@ -27,3 +27,24 @@ on the submit button. Then check the following:
// Write your code here
+// document.getElementById("submit").addEventListener("click", submit);
+// function submit(){
+// let url = `https://codeyourfuture.herokuapp.com/api/messages`;
+// fetch(url).then(function(response) {
+// return response.text();
+// }).then(function(message){
+// let myMessage = document.getElementById("message-list").value;
+// console.log(message);
+// myMessage.innerText = message.;
+// console.log(myMessage);
+// return;
+
+// })
+// }
+
+let myObj ={
+ name: "Ade",
+ Age: 37
+}
+localStorage.setItem("myObj", myObj);
+console.log(localStorage);
diff --git a/Week-3/Homework/mandatory/1-alarmclock/alarmclock.js b/Week-3/Homework/mandatory/1-alarmclock/alarmclock.js
index 6ca81cd..34757a7 100644
--- a/Week-3/Homework/mandatory/1-alarmclock/alarmclock.js
+++ b/Week-3/Homework/mandatory/1-alarmclock/alarmclock.js
@@ -1,4 +1,24 @@
-function setAlarm() {}
+ function setAlarm() {
+ let alarmSet = document.getElementById("alarmSet");
+ remainingTime = document.getElementById("timeRemaining");
+ let time = parseInt(alarmSet.value);
+
+ let timeIn = setInterval(function(){
+ let min = Math.floor(time/60);
+ let sec = time-min * 60;
+
+ remainingTime.textContent = ("Time Remaining: ") + (min>9?min:"0" +min) + ":" + (sec>9?sec:"0" + sec);
+
+ if(time === 0){
+ playAlarm();
+
+ return clearInterval(timeIn);
+
+ }
+ time--;
+ }, 1000);
+
+ }
// DO NOT EDIT BELOW HERE
@@ -17,7 +37,7 @@ function setup() {
function playAlarm() {
audio.play();
}
-
+
function pauseAlarm() {
audio.pause();
}
diff --git a/Week-3/Homework/mandatory/1-alarmclock/index.html b/Week-3/Homework/mandatory/1-alarmclock/index.html
index ab7d582..cc2550c 100644
--- a/Week-3/Homework/mandatory/1-alarmclock/index.html
+++ b/Week-3/Homework/mandatory/1-alarmclock/index.html
@@ -11,7 +11,6 @@
/>
-
+
+
diff --git a/Week-3/Homework/mandatory/2-quotegenerator/quotes.js b/Week-3/Homework/mandatory/2-quotegenerator/quotes.js
index 39ab245..48fd7f2 100644
--- a/Week-3/Homework/mandatory/2-quotegenerator/quotes.js
+++ b/Week-3/Homework/mandatory/2-quotegenerator/quotes.js
@@ -1,492 +1,543 @@
-// DO NOT EDIT BELOW HERE
+ // DO NOT EDIT BELOW HERE
-// A function which will return one item, at
-// random, from the given array.
-//
-// Parameters
-// ----------
-// choices: an array of items to pick from.
-//
-// Returns
-// -------
-// One item of the given array.
-//
-// Examples of use
-// ---------------
-// pickFromArray([1,2,3,4]) //maybe returns 2
-// 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)];
-}
-// A list of quotes you can use in your app.
-// Feel free to edit them, and to add your own favourites.
-const quotes = [
- {
- quote: "Life isn’t about getting and having, it’s about giving and being.",
- author: "Kevin Kruse",
- },
- {
- quote: "Whatever the mind of man can conceive and believe, it can achieve.",
- author: "Napoleon Hill",
- },
- {
- quote: "Strive not to be a success, but rather to be of value.",
- author: "Albert Einstein",
- },
- {
- quote:
- "Two roads diverged in a wood, and I—I took the one less traveled by, And that has made all the difference.",
- author: "Robert Frost",
- },
- {
- quote: "I attribute my success to this: I never gave or took any excuse.",
- author: "Florence Nightingale",
- },
- {
- quote: "You miss 100% of the shots you don’t take.",
- author: "Wayne Gretzky",
- },
- {
- quote:
- "I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times I’ve been trusted to take the game winning shot and missed. I’ve failed over and over and over again in my life. And that is why I succeed.",
- author: "Michael Jordan",
- },
- {
- quote:
- "The most difficult thing is the decision to act, the rest is merely tenacity.",
- author: "Amelia Earhart",
- },
- {
- quote: "Every strike brings me closer to the next home run.",
- author: "Babe Ruth",
- },
- {
- quote: "Definiteness of purpose is the starting point of all achievement.",
- author: "W. Clement Stone",
- },
- {
- quote: "We must balance conspicuous consumption with conscious capitalism.",
- author: "Kevin Kruse",
- },
- {
- quote: "Life is what happens to you while you’re busy making other plans.",
- author: "John Lennon",
- },
- {
- quote: "We become what we think about.",
- author: "Earl Nightingale",
- },
- {
- quote:
- "Twenty years from now you will be more disappointed by the things that you didn’t do than by the ones you did do, so throw off the bowlines, sail away from safe harbor, catch the trade winds in your sails. Explore, Dream, Discover.",
- author: "Mark Twain",
- },
- {
- quote: "Life is 10% what happens to me and 90% of how I react to it.",
- author: "Charles Swindoll",
- },
- {
- quote:
- "The most common way people give up their power is by thinking they don’t have any.",
- author: "Alice Walker",
- },
- {
- quote: "The mind is everything. What you think you become.",
- author: "Buddha",
- },
- {
- quote:
- "The best time to plant a tree was 20 years ago. The second best time is now.",
- author: "Chinese Proverb",
- },
- {
- quote: "An unexamined life is not worth living.",
- author: "Socrates",
- },
- {
- quote: "Eighty percent of success is showing up.",
- author: "Woody Allen",
- },
- {
- quote:
- "Your time is limited, so don’t waste it living someone else’s life.",
- author: "Steve Jobs",
- },
- {
- quote: "Winning isn’t everything, but wanting to win is.",
- author: "Vince Lombardi",
- },
- {
- quote:
- "I am not a product of my circumstances. I am a product of my decisions.",
- author: "Stephen Covey",
- },
- {
- quote:
- "Every child is an artist. The problem is how to remain an artist once he grows up.",
- author: "Pablo Picasso",
- },
- {
- quote:
- "You can never cross the ocean until you have the courage to lose sight of the shore.",
- author: "Christopher Columbus",
- },
- {
- quote:
- "I’ve learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel.",
- author: "Maya Angelou",
- },
- {
- quote: "Either you run the day, or the day runs you.",
- author: "Jim Rohn",
- },
- {
- quote: "Whether you think you can or you think you can’t, you’re right.",
- author: "Henry Ford",
- },
- {
- quote:
- "The two most important days in your life are the day you are born and the day you find out why.",
- author: "Mark Twain",
- },
- {
- quote:
- "Whatever you can do, or dream you can, begin it. Boldness has genius, power and magic in it.",
- author: "Johann Wolfgang von Goethe",
- },
- {
- quote: "The best revenge is massive success.",
- author: "Frank Sinatra",
- },
- {
- quote:
- "People often say that motivation doesn’t last. Well, neither does bathing. That’s why we recommend it daily.",
- author: "Zig Ziglar",
- },
- {
- quote: "Life shrinks or expands in proportion to one’s courage.",
- author: "Anais Nin",
- },
- {
- quote:
- "If you hear a voice within you say “you cannot paint,” then by all means paint and that voice will be silenced.",
- author: "Vincent Van Gogh",
- },
- {
- quote:
- "There is only one way to avoid criticism: do nothing, say nothing, and be nothing.",
- author: "Aristotle",
- },
- {
- quote:
- "Ask and it will be given to you; search, and you will find; knock and the door will be opened for you.",
- author: "Jesus",
- },
- {
- quote:
- "The only person you are destined to become is the person you decide to be.",
- author: "Ralph Waldo Emerson",
- },
- {
- quote:
- "Go confidently in the direction of your dreams. Live the life you have imagined.",
- author: "Henry David Thoreau",
- },
- {
- quote:
- "When I stand before God at the end of my life, I would hope that I would not have a single bit of talent left and could say, I used everything you gave me.",
- author: "Erma Bombeck",
- },
- {
- quote:
- "Few things can help an individual more than to place responsibility on him, and to let him know that you trust him.",
- author: "Booker T. Washington",
- },
- {
- quote:
- "Certain things catch your eye, but pursue only those that capture the heart.",
- author: " Ancient Indian Proverb",
- },
- {
- quote: "Believe you can and you’re halfway there.",
- author: "Theodore Roosevelt",
- },
- {
- quote: "Everything you’ve ever wanted is on the other side of fear.",
- author: "George Addair",
- },
- {
- quote:
- "We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.",
- author: "Plato",
- },
- {
- quote:
- "Teach thy tongue to say, “I do not know,” and thous shalt progress.",
- author: "Maimonides",
- },
- {
- quote: "Start where you are. Use what you have. Do what you can.",
- author: "Arthur Ashe",
- },
- {
- quote:
- "When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy’. They told me I didn’t understand the assignment, and I told them they didn’t understand life.",
- author: "John Lennon",
- },
- {
- quote: "Fall seven times and stand up eight.",
- author: "Japanese Proverb",
- },
- {
- quote:
- "When one door of happiness closes, another opens, but often we look so long at the closed door that we do not see the one that has been opened for us.",
- author: "Helen Keller",
- },
- {
- quote: "Everything has beauty, but not everyone can see.",
- author: "Confucius",
- },
- {
- quote:
- "How wonderful it is that nobody need wait a single moment before starting to improve the world.",
- author: "Anne Frank",
- },
- {
- quote: "When I let go of what I am, I become what I might be.",
- author: "Lao Tzu",
- },
- {
- quote:
- "Life is not measured by the number of breaths we take, but by the moments that take our breath away.",
- author: "Maya Angelou",
- },
- {
- quote:
- "Happiness is not something readymade. It comes from your own actions.",
- author: "Dalai Lama",
- },
- {
- quote:
- "If you’re offered a seat on a rocket ship, don’t ask what seat! Just get on.",
- author: "Sheryl Sandberg",
- },
- {
- quote:
- "First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods. Third, adjust all your means to that end.",
- author: "Aristotle",
- },
- {
- quote: "If the wind will not serve, take to the oars.",
- author: "Latin Proverb",
- },
- {
- quote:
- "You can’t fall if you don’t climb. But there’s no joy in living your whole life on the ground.",
- author: "Unknown",
- },
- {
- quote:
- "We must believe that we are gifted for something, and that this thing, at whatever cost, must be attained.",
- author: "Marie Curie",
- },
- {
- quote:
- "Too many of us are not living our dreams because we are living our fears.",
- author: "Les Brown",
- },
- {
- quote:
- "Challenges are what make life interesting and overcoming them is what makes life meaningful.",
- author: "Joshua J. Marine",
- },
- {
- quote: "If you want to lift yourself up, lift up someone else.",
- author: "Booker T. Washington",
- },
- {
- quote:
- "I have been impressed with the urgency of doing. Knowing is not enough; we must apply. Being willing is not enough; we must do.",
- author: "Leonardo da Vinci",
- },
- {
- quote:
- "Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.",
- author: "Jamie Paolinetti",
- },
- {
- quote:
- "You take your life in your own hands, and what happens? A terrible thing, no one to blame.",
- author: "Erica Jong",
- },
- {
- quote:
- "What’s money? A man is a success if he gets up in the morning and goes to bed at night and in between does what he wants to do.",
- author: "Bob Dylan",
- },
- {
- quote: "I didn’t fail the test. I just found 100 ways to do it wrong.",
- author: "Benjamin Franklin",
- },
- {
- quote:
- "In order to succeed, your desire for success should be greater than your fear of failure.",
- author: "Bill Cosby",
- },
- {
- quote: "A person who never made a mistake never tried anything new.",
- author: " Albert Einstein",
- },
- {
- quote:
- "The person who says it cannot be done should not interrupt the person who is doing it.",
- author: "Chinese Proverb",
- },
- {
- quote: "There are no traffic jams along the extra mile.",
- author: "Roger Staubach",
- },
- {
- quote: "It is never too late to be what you might have been.",
- author: "George Eliot",
- },
- {
- quote: "You become what you believe.",
- author: "Oprah Winfrey",
- },
- {
- quote: "I would rather die of passion than of boredom.",
- author: "Vincent van Gogh",
- },
- {
- quote:
- "A truly rich man is one whose children run into his arms when his hands are empty.",
- author: "Unknown",
- },
- {
- quote:
- "It is not what you do for your children, but what you have taught them to do for themselves, that will make them successful human beings.",
- author: "Ann Landers",
- },
- {
- quote:
- "If you want your children to turn out well, spend twice as much time with them, and half as much money.",
- author: "Abigail Van Buren",
- },
- {
- quote:
- "Build your own dreams, or someone else will hire you to build theirs.",
- author: "Farrah Gray",
- },
- {
- quote:
- "The battles that count aren’t the ones for gold medals. The struggles within yourself–the invisible battles inside all of us–that’s where it’s at.",
- author: "Jesse Owens",
- },
- {
- quote: "Education costs money. But then so does ignorance.",
- author: "Sir Claus Moser",
- },
- {
- quote:
- "I have learned over the years that when one’s mind is made up, this diminishes fear.",
- author: "Rosa Parks",
- },
- {
- quote: "It does not matter how slowly you go as long as you do not stop.",
- author: "Confucius",
- },
- {
- quote:
- "If you look at what you have in life, you’ll always have more. If you look at what you don’t have in life, you’ll never have enough.",
- author: "Oprah Winfrey",
- },
- {
- quote:
- "Remember that not getting what you want is sometimes a wonderful stroke of luck.",
- author: "Dalai Lama",
- },
- {
- quote: "You can’t use up creativity. The more you use, the more you have.",
- author: "Maya Angelou",
- },
- {
- quote: "Dream big and dare to fail.",
- author: "Norman Vaughan",
- },
- {
- quote:
- "Our lives begin to end the day we become silent about things that matter.",
- author: "Martin Luther King Jr.",
- },
- {
- quote: "Do what you can, where you are, with what you have.",
- author: "Teddy Roosevelt",
- },
- {
- quote:
- "If you do what you’ve always done, you’ll get what you’ve always gotten.",
- author: "Tony Robbins",
- },
- {
- quote: "Dreaming, after all, is a form of planning.",
- author: "Gloria Steinem",
- },
- {
- quote:
- "It’s your place in the world; it’s your life. Go on and do all you can with it, and make it the life you want to live.",
- author: "Mae Jemison",
- },
- {
- quote:
- "You may be disappointed if you fail, but you are doomed if you don’t try.",
- author: "Beverly Sills",
- },
- {
- quote: "Remember no one can make you feel inferior without your consent.",
- author: "Eleanor Roosevelt",
- },
- {
- quote: "Life is what we make it, always has been, always will be.",
- author: "Grandma Moses",
- },
- {
- quote:
- "The question isn’t who is going to let me; it’s who is going to stop me.",
- author: "Ayn Rand",
- },
- {
- quote:
- "When everything seems to be going against you, remember that the airplane takes off against the wind, not with it.",
- author: "Henry Ford",
- },
- {
- quote:
- "It’s not the years in your life that count. It’s the life in your years.",
- author: "Abraham Lincoln",
- },
- {
- quote: "Change your thoughts and you change your world.",
- author: "Norman Vincent Peale",
- },
- {
- quote:
- "Either write something worth reading or do something worth writing.",
- author: "Benjamin Franklin",
- },
- {
- quote: "Nothing is impossible, the word itself says, “I’m possible!”",
- author: "–Audrey Hepburn",
- },
- {
- quote: "The only way to do great work is to love what you do.",
- author: "Steve Jobs",
- },
- {
- quote: "If you can dream it, you can achieve it.",
- author: "Zig Ziglar",
- },
-];
+ // A function which will return one item, at
+ // random, from the given array.
+ //
+ // Parameters
+ // ----------
+ // choices: an array of items to pick from.
+ //
+ // Returns
+ // -------
+ // One item of the given array.
+ //
+ // Examples of use
+ // ---------------
+ // pickFromArray([1,2,3,4]) //maybe returns 2
+ // pickFromArray(coloursArray) //maybe returns "#F38630"
+ //
+ // You DO NOT need to understand how this function works.
+
+
+
+ // function pickFromArray(quotes) {
+
+
+ // return quotes[Math.floor(Math.random() * quotes.length)] ;
+
+
+ // }
+ //Function to randomly select a quote value and return a random quote object from the quotes array
+ function getRandomQuote () {
+ let randomNumber = Math.floor(Math.random() * (quotes.length));
+ let randomQuote = quotes[randomNumber];
+ return randomQuote;
+ }
+
+ //Function to select random rgb color value
+ function getRandomColor () {
+ let color1 = Math.floor(Math.random() * 192 );
+ let color2 = Math.floor(Math.random() * 191 );
+ let color3 = Math.floor(Math.random() * 191 );
+ let randomColor = 'rgb(' + color1 + ',' + color2 + ',' + color3 + ')';
+ return randomColor;
+ }
+
+ function printQuote () {
+ let quotes = getRandomQuote ();
+ let quoteContainer = document.getElementById("quote-box");
+ let quoteString = `
${quotes.quote}
${quotes.author}`;
+ if (quotes.citation) {quoteString += `${quotes.citation}`}
+ if (quotes.year) {quoteString +=`
`}
+ else {quoteString += ''};
+ quoteContainer.innerHTML = quoteString;
+
+ //assigns random color value to document background color
+ document.body.style.backgroundColor = getRandomColor ();
+ }
+
+ //Quote automatically refreshes every 15 seconds
+ setInterval(function(){
+ printQuote ();
+ }, 10000);
+
+ //Event listener on LoadQuote button to generate new quote
+ document.getElementById("myButton").addEventListener("click", printQuote, false);
+ // document.getElementById("loadQuote").addEventListener("click");
+
+
+
+
+
+
+
+ // A list of quotes you can use in your app.
+ // Feel free to edit them, and to add your own favourites.
+ const quotes = [
+ {
+ quote: "Life isn’t about getting and having, it’s about giving and being.",
+ author: "Kevin Kruse",
+ },
+ {
+ quote: "Whatever the mind of man can conceive and believe, it can achieve.",
+ author: "Napoleon Hill",
+ },
+ {
+ quote: "Strive not to be a success, but rather to be of value.",
+ author: "Albert Einstein",
+ },
+ {
+ quote:
+ "Two roads diverged in a wood, and I—I took the one less traveled by, And that has made all the difference.",
+ author: "Robert Frost",
+ },
+ {
+ quote: "I attribute my success to this: I never gave or took any excuse.",
+ author: "Florence Nightingale",
+ },
+ {
+ quote: "You miss 100% of the shots you don’t take.",
+ author: "Wayne Gretzky",
+ },
+ {
+ quote:
+ "I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times I’ve been trusted to take the game winning shot and missed. I’ve failed over and over and over again in my life. And that is why I succeed.",
+ author: "Michael Jordan",
+ },
+ {
+ quote:
+ "The most difficult thing is the decision to act, the rest is merely tenacity.",
+ author: "Amelia Earhart",
+ },
+ {
+ quote: "Every strike brings me closer to the next home run.",
+ author: "Babe Ruth",
+ },
+ {
+ quote: "Definiteness of purpose is the starting point of all achievement.",
+ author: "W. Clement Stone",
+ },
+ {
+ quote: "We must balance conspicuous consumption with conscious capitalism.",
+ author: "Kevin Kruse",
+ },
+ {
+ quote: "Life is what happens to you while you’re busy making other plans.",
+ author: "John Lennon",
+ },
+ {
+ quote: "We become what we think about.",
+ author: "Earl Nightingale",
+ },
+ {
+ quote:
+ "Twenty years from now you will be more disappointed by the things that you didn’t do than by the ones you did do, so throw off the bowlines, sail away from safe harbor, catch the trade winds in your sails. Explore, Dream, Discover.",
+ author: "Mark Twain",
+ },
+ {
+ quote: "Life is 10% what happens to me and 90% of how I react to it.",
+ author: "Charles Swindoll",
+ },
+ {
+ quote:
+ "The most common way people give up their power is by thinking they don’t have any.",
+ author: "Alice Walker",
+ },
+ {
+ quote: "The mind is everything. What you think you become.",
+ author: "Buddha",
+ },
+ {
+ quote:
+ "The best time to plant a tree was 20 years ago. The second best time is now.",
+ author: "Chinese Proverb",
+ },
+ {
+ quote: "An unexamined life is not worth living.",
+ author: "Socrates",
+ },
+ {
+ quote: "Eighty percent of success is showing up.",
+ author: "Woody Allen",
+ },
+ {
+ quote:
+ "Your time is limited, so don’t waste it living someone else’s life.",
+ author: "Steve Jobs",
+ },
+ {
+ quote: "Winning isn’t everything, but wanting to win is.",
+ author: "Vince Lombardi",
+ },
+ {
+ quote:
+ "I am not a product of my circumstances. I am a product of my decisions.",
+ author: "Stephen Covey",
+ },
+ {
+ quote:
+ "Every child is an artist. The problem is how to remain an artist once he grows up.",
+ author: "Pablo Picasso",
+ },
+ {
+ quote:
+ "You can never cross the ocean until you have the courage to lose sight of the shore.",
+ author: "Christopher Columbus",
+ },
+ {
+ quote:
+ "I’ve learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel.",
+ author: "Maya Angelou",
+ },
+ {
+ quote: "Either you run the day, or the day runs you.",
+ author: "Jim Rohn",
+ },
+ {
+ quote: "Whether you think you can or you think you can’t, you’re right.",
+ author: "Henry Ford",
+ },
+ {
+ quote:
+ "The two most important days in your life are the day you are born and the day you find out why.",
+ author: "Mark Twain",
+ },
+ {
+ quote:
+ "Whatever you can do, or dream you can, begin it. Boldness has genius, power and magic in it.",
+ author: "Johann Wolfgang von Goethe",
+ },
+ {
+ quote: "The best revenge is massive success.",
+ author: "Frank Sinatra",
+ },
+ {
+ quote:
+ "People often say that motivation doesn’t last. Well, neither does bathing. That’s why we recommend it daily.",
+ author: "Zig Ziglar",
+ },
+ {
+ quote: "Life shrinks or expands in proportion to one’s courage.",
+ author: "Anais Nin",
+ },
+ {
+ quote:
+ "If you hear a voice within you say “you cannot paint,” then by all means paint and that voice will be silenced.",
+ author: "Vincent Van Gogh",
+ },
+ {
+ quote:
+ "There is only one way to avoid criticism: do nothing, say nothing, and be nothing.",
+ author: "Aristotle",
+ },
+ {
+ quote:
+ "Ask and it will be given to you; search, and you will find; knock and the door will be opened for you.",
+ author: "Jesus",
+ },
+ {
+ quote:
+ "The only person you are destined to become is the person you decide to be.",
+ author: "Ralph Waldo Emerson",
+ },
+ {
+ quote:
+ "Go confidently in the direction of your dreams. Live the life you have imagined.",
+ author: "Henry David Thoreau",
+ },
+ {
+ quote:
+ "When I stand before God at the end of my life, I would hope that I would not have a single bit of talent left and could say, I used everything you gave me.",
+ author: "Erma Bombeck",
+ },
+ {
+ quote:
+ "Few things can help an individual more than to place responsibility on him, and to let him know that you trust him.",
+ author: "Booker T. Washington",
+ },
+ {
+ quote:
+ "Certain things catch your eye, but pursue only those that capture the heart.",
+ author: " Ancient Indian Proverb",
+ },
+ {
+ quote: "Believe you can and you’re halfway there.",
+ author: "Theodore Roosevelt",
+ },
+ {
+ quote: "Everything you’ve ever wanted is on the other side of fear.",
+ author: "George Addair",
+ },
+ {
+ quote:
+ "We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.",
+ author: "Plato",
+ },
+ {
+ quote:
+ "Teach thy tongue to say, “I do not know,” and thous shalt progress.",
+ author: "Maimonides",
+ },
+ {
+ quote: "Start where you are. Use what you have. Do what you can.",
+ author: "Arthur Ashe",
+ },
+ {
+ quote:
+ "When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy’. They told me I didn’t understand the assignment, and I told them they didn’t understand life.",
+ author: "John Lennon",
+ },
+ {
+ quote: "Fall seven times and stand up eight.",
+ author: "Japanese Proverb",
+ },
+ {
+ quote:
+ "When one door of happiness closes, another opens, but often we look so long at the closed door that we do not see the one that has been opened for us.",
+ author: "Helen Keller",
+ },
+ {
+ quote: "Everything has beauty, but not everyone can see.",
+ author: "Confucius",
+ },
+ {
+ quote:
+ "How wonderful it is that nobody need wait a single moment before starting to improve the world.",
+ author: "Anne Frank",
+ },
+ {
+ quote: "When I let go of what I am, I become what I might be.",
+ author: "Lao Tzu",
+ },
+ {
+ quote:
+ "Life is not measured by the number of breaths we take, but by the moments that take our breath away.",
+ author: "Maya Angelou",
+ },
+ {
+ quote:
+ "Happiness is not something readymade. It comes from your own actions.",
+ author: "Dalai Lama",
+ },
+ {
+ quote:
+ "If you’re offered a seat on a rocket ship, don’t ask what seat! Just get on.",
+ author: "Sheryl Sandberg",
+ },
+ {
+ quote:
+ "First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods. Third, adjust all your means to that end.",
+ author: "Aristotle",
+ },
+ {
+ quote: "If the wind will not serve, take to the oars.",
+ author: "Latin Proverb",
+ },
+ {
+ quote:
+ "You can’t fall if you don’t climb. But there’s no joy in living your whole life on the ground.",
+ author: "Unknown",
+ },
+ {
+ quote:
+ "We must believe that we are gifted for something, and that this thing, at whatever cost, must be attained.",
+ author: "Marie Curie",
+ },
+ {
+ quote:
+ "Too many of us are not living our dreams because we are living our fears.",
+ author: "Les Brown",
+ },
+ {
+ quote:
+ "Challenges are what make life interesting and overcoming them is what makes life meaningful.",
+ author: "Joshua J. Marine",
+ },
+ {
+ quote: "If you want to lift yourself up, lift up someone else.",
+ author: "Booker T. Washington",
+ },
+ {
+ quote:
+ "I have been impressed with the urgency of doing. Knowing is not enough; we must apply. Being willing is not enough; we must do.",
+ author: "Leonardo da Vinci",
+ },
+ {
+ quote:
+ "Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.",
+ author: "Jamie Paolinetti",
+ },
+ {
+ quote:
+ "You take your life in your own hands, and what happens? A terrible thing, no one to blame.",
+ author: "Erica Jong",
+ },
+ {
+ quote:
+ "What’s money? A man is a success if he gets up in the morning and goes to bed at night and in between does what he wants to do.",
+ author: "Bob Dylan",
+ },
+ {
+ quote: "I didn’t fail the test. I just found 100 ways to do it wrong.",
+ author: "Benjamin Franklin",
+ },
+ {
+ quote:
+ "In order to succeed, your desire for success should be greater than your fear of failure.",
+ author: "Bill Cosby",
+ },
+ {
+ quote: "A person who never made a mistake never tried anything new.",
+ author: " Albert Einstein",
+ },
+ {
+ quote:
+ "The person who says it cannot be done should not interrupt the person who is doing it.",
+ author: "Chinese Proverb",
+ },
+ {
+ quote: "There are no traffic jams along the extra mile.",
+ author: "Roger Staubach",
+ },
+ {
+ quote: "It is never too late to be what you might have been.",
+ author: "George Eliot",
+ },
+ {
+ quote: "You become what you believe.",
+ author: "Oprah Winfrey",
+ },
+ {
+ quote: "I would rather die of passion than of boredom.",
+ author: "Vincent van Gogh",
+ },
+ {
+ quote:
+ "A truly rich man is one whose children run into his arms when his hands are empty.",
+ author: "Unknown",
+ },
+ {
+ quote:
+ "It is not what you do for your children, but what you have taught them to do for themselves, that will make them successful human beings.",
+ author: "Ann Landers",
+ },
+ {
+ quote:
+ "If you want your children to turn out well, spend twice as much time with them, and half as much money.",
+ author: "Abigail Van Buren",
+ },
+ {
+ quote:
+ "Build your own dreams, or someone else will hire you to build theirs.",
+ author: "Farrah Gray",
+ },
+ {
+ quote:
+ "The battles that count aren’t the ones for gold medals. The struggles within yourself–the invisible battles inside all of us–that’s where it’s at.",
+ author: "Jesse Owens",
+ },
+ {
+ quote: "Education costs money. But then so does ignorance.",
+ author: "Sir Claus Moser",
+ },
+ {
+ quote:
+ "I have learned over the years that when one’s mind is made up, this diminishes fear.",
+ author: "Rosa Parks",
+ },
+ {
+ quote: "It does not matter how slowly you go as long as you do not stop.",
+ author: "Confucius",
+ },
+ {
+ quote:
+ "If you look at what you have in life, you’ll always have more. If you look at what you don’t have in life, you’ll never have enough.",
+ author: "Oprah Winfrey",
+ },
+ {
+ quote:
+ "Remember that not getting what you want is sometimes a wonderful stroke of luck.",
+ author: "Dalai Lama",
+ },
+ {
+ quote: "You can’t use up creativity. The more you use, the more you have.",
+ author: "Maya Angelou",
+ },
+ {
+ quote: "Dream big and dare to fail.",
+ author: "Norman Vaughan",
+ },
+ {
+ quote:
+ "Our lives begin to end the day we become silent about things that matter.",
+ author: "Martin Luther King Jr.",
+ },
+ {
+ quote: "Do what you can, where you are, with what you have.",
+ author: "Teddy Roosevelt",
+ },
+ {
+ quote:
+ "If you do what you’ve always done, you’ll get what you’ve always gotten.",
+ author: "Tony Robbins",
+ },
+ {
+ quote: "Dreaming, after all, is a form of planning.",
+ author: "Gloria Steinem",
+ },
+ {
+ quote:
+ "It’s your place in the world; it’s your life. Go on and do all you can with it, and make it the life you want to live.",
+ author: "Mae Jemison",
+ },
+ {
+ quote:
+ "You may be disappointed if you fail, but you are doomed if you don’t try.",
+ author: "Beverly Sills",
+ },
+ {
+ quote: "Remember no one can make you feel inferior without your consent.",
+ author: "Eleanor Roosevelt",
+ },
+ {
+ quote: "Life is what we make it, always has been, always will be.",
+ author: "Grandma Moses",
+ },
+ {
+ quote:
+ "The question isn’t who is going to let me; it’s who is going to stop me.",
+ author: "Ayn Rand",
+ },
+ {
+ quote:
+ "When everything seems to be going against you, remember that the airplane takes off against the wind, not with it.",
+ author: "Henry Ford",
+ },
+ {
+ quote:
+ "It’s not the years in your life that count. It’s the life in your years.",
+ author: "Abraham Lincoln",
+ },
+ {
+ quote: "Change your thoughts and you change your world.",
+ author: "Norman Vincent Peale",
+ },
+ {
+ quote:
+ "Either write something worth reading or do something worth writing.",
+ author: "Benjamin Franklin",
+ },
+ {
+ quote: "Nothing is impossible, the word itself says, “I’m possible!”",
+ author: "–Audrey Hepburn",
+ },
+ {
+ quote: "The only way to do great work is to love what you do.",
+ author: "Steve Jobs",
+ },
+ {
+ quote: "If you can dream it, you can achieve it.",
+ author: "Zig Ziglar",
+ },
+ ];
diff --git a/Week-3/Homework/mandatory/2-quotegenerator/style.css b/Week-3/Homework/mandatory/2-quotegenerator/style.css
index 63cedf2..1a0dac5 100644
--- a/Week-3/Homework/mandatory/2-quotegenerator/style.css
+++ b/Week-3/Homework/mandatory/2-quotegenerator/style.css
@@ -1 +1,93 @@
-/** Write your CSS in here **/
+body {
+ /*text-align: center;*/
+ background-size: cover;
+ color: white;
+ font-family: 'Roboto', sans-serif;;
+ background-color: rgb(95,207,128);
+ }
+ #quote-box {
+ position: absolute;
+ top: 14%;
+ left: 10%;
+ right: 10%;
+ width: 80%;
+ line-height: .5;
+ }
+ .quote {
+ font-size: 2rem;
+ font-weight: 400;
+ line-height: 2;
+ text-shadow: 0 1px 1px rgba(0,0,0, .8);
+ position: relative;
+ margin: 0;
+ }
+ .quote:before, .quote:after {
+ font-size: 2rem;
+ line-height: 2.5rem;
+ position: absolute;
+ }
+ .quote:before {
+ content: "“";
+ top: .25em;
+ left: -.5em;
+ }
+ .quote:after {
+ content: "”";
+ bottom: -.1em;
+ margin-left: .1em;
+ position: absolute;
+ }
+ .author {
+ font-size: 2.5rem;
+ letter-spacing: 0.5em;
+ line-height: 5;
+ text-align: right;
+ margin-top: 1rem;
+ margin-right: 4em;
+ }
+ .author:before {
+ content: "—";
+ }
+ .citation {
+ font-size: 1.5rem;
+ font-style: italic;
+ }
+ .citation:before {
+ content: ", ";
+ font-style: normal;
+ }
+
+ #myButton {
+ font-size: 2.5rem;;
+ position: fixed;
+ width: 7em;
+ display: inline-block;
+ left: 50%;
+ margin: 0 auto;
+ bottom: 150px;
+ border-radius: 15px;
+ border: 2px solid rgb(117, 86, 86);
+ color: #fff;
+ background-color: rgba(255,255,255, 0);
+ margin-top: 15px;
+ padding: 15px 0;
+ transition: .5s ;
+ }
+ #loadQuote:hover {
+ background-color: rgba(255,255,255,.25);
+ }
+ #myButton:focus {
+ outline: none;
+ }
+
+ @media (max-width: 420px) {
+ .quote {
+ font-size: 2.5rem;
+ }
+ .quote:before, .quote:after {
+ font-size: 3rem;
+ }
+ .author {
+ font-size: 1.5rem;
+ }
+ }
\ No newline at end of file
diff --git a/Week-3/Homework/mandatory/3-slideshow/index.html b/Week-3/Homework/mandatory/3-slideshow/index.html
index 39cd40e..fb9c744 100644
--- a/Week-3/Homework/mandatory/3-slideshow/index.html
+++ b/Week-3/Homework/mandatory/3-slideshow/index.html
@@ -1,17 +1,44 @@
-
-
-
- Slideshow
-
-
-
-
-
-
-
-
+
+
+
+
+ Slideshow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week-3/Homework/mandatory/3-slideshow/slideshow.js b/Week-3/Homework/mandatory/3-slideshow/slideshow.js
index b55091c..a040b5a 100644
--- a/Week-3/Homework/mandatory/3-slideshow/slideshow.js
+++ b/Week-3/Homework/mandatory/3-slideshow/slideshow.js
@@ -1 +1,42 @@
-// Write your code here
+
+const container = document.querySelector(".img-slider");
+
+const imgSlider = document.querySelectorAll(".img-slider img");
+
+const previousBtn = document.querySelector("#previousBtn");
+const forwardBtn = document.querySelector("#forwardBtn");
+let counter = 1;
+const size = imgSlider[0].clientWidth;
+container.style.transform = `translateX(`+ (-size *counter) + `px)`;
+
+forwardBtn.addEventListener("click", ()=>{
+ if(counter >= imgSlider.length -1) return;
+ container.style.transition = "transform 0.4s ease-in-out";
+ counter++;
+
+ container.style.transform = `translateX(`+ (-size *counter) + `px)`;
+})
+
+previousBtn.addEventListener("click", ()=>{
+ if(counter <= 0) return;
+ container.style.transition = "transform 0.4s ease-in-out";
+ counter--;
+
+ container.style.transform = `translateX(`+ (-size *counter) + `px)`;
+})
+
+container.addEventListener('transitionend', ()=> {
+
+ if(imgSlider[counter].id === 'lastClone'){
+ container.style.transition = "none";
+ counter = imgSlider.length - 2;
+ container.style.transform = `translateX(`+ (-size *counter) + `px)`;
+ }
+ if(imgSlider[counter].id === 'firstClone'){
+ container.style.transition = "none";
+ counter = imgSlider.length - counter;
+ container.style.transform = `translateX(`+ (-size *counter) + `px)`;
+ }
+
+
+ });
\ No newline at end of file
diff --git a/Week-3/Homework/mandatory/3-slideshow/style.css b/Week-3/Homework/mandatory/3-slideshow/style.css
index 63cedf2..2ceccf2 100644
--- a/Week-3/Homework/mandatory/3-slideshow/style.css
+++ b/Week-3/Homework/mandatory/3-slideshow/style.css
@@ -1 +1,38 @@
/** Write your CSS in here **/
+
+*{
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+}
+
+.container{
+
+ width: 30%;
+ margin: auto;
+ overflow: hidden;
+ border: 4px solid black;
+ position: relative;
+}
+.img-slider{
+
+ display: flex;
+ width: 100%;
+
+
+}
+ .myBtn{
+display: flex;
+justify-content: center;
+
+}
+#previousBtn{
+ padding: 10px;
+ border-radius: 5px;
+ background-color: royalblue;
+}
+#forwardBtn{
+ padding: 10px;
+ border-radius: 5px;
+ background-color: skyblue;
+}
\ No newline at end of file
diff --git a/Week-3/InClass/Callbacks/exercise-1/exercise.js b/Week-3/InClass/Callbacks/exercise-1/exercise.js
index 40f06b0..1d2bd1a 100644
--- a/Week-3/InClass/Callbacks/exercise-1/exercise.js
+++ b/Week-3/InClass/Callbacks/exercise-1/exercise.js
@@ -2,12 +2,35 @@
================
EXERCISE 1
+
Task 1
Using setTimeout, change the background colour of the page after 5 seconds (5000 milliseconds).
+
Task 2
Update your code to make the colour change every 5 seconds to something different. Hint: try searching for setInterval. Complete the exercises in this CodePen
Prefer to work on a codepen? https://codepen.io/makanti/pen/abOreLg
================
-*/
\ No newline at end of file
+*/
+//Task 1
+setTimeout(function(){
+
+ document.body.style.backgroundColor = "blue";
+
+}, 5000);
+
+//Task 2
+
+function getRandomColor () {
+ let color1 = Math.floor(Math.random() * 255 );
+ let color2 = Math.floor(Math.random() * 255 );
+ let color3 = Math.floor(Math.random() * 20 );
+ let randomColor = 'rgb(' + color1 + ',' + color2 + ',' + color3 + ')';
+ return randomColor;
+ }
+
+setInterval(function change() {
+
+ document.body.style.backgroundColor = getRandomColor();
+}, 5000);
\ No newline at end of file
diff --git a/Week-3/InClass/Callbacks/exercise-2/exercise.js b/Week-3/InClass/Callbacks/exercise-2/exercise.js
index eca9595..d76df2e 100644
--- a/Week-3/InClass/Callbacks/exercise-2/exercise.js
+++ b/Week-3/InClass/Callbacks/exercise-2/exercise.js
@@ -1,6 +1,7 @@
/*
================
Exercise 2
+
----------
You are given the following list of movies
@@ -42,6 +43,7 @@ const movies = [
haveWatched: true,
},
{
+
title: "A Twelve-Year Night",
director: "Álvaro Brechner",
type: "horror",
@@ -62,9 +64,152 @@ const movies = [
];
// create showMovies function
+let allMovies = document.getElementById("all-movies");
+let movieNumber = document.getElementById("movies-number");
+let myMovies = function(){
+ movies.forEach(function (movie){
+ let pElement = document.createElement("p");
+ // console.log(pElement)
+ let quoteString = `${movie.title} directed by ${movie.director}`;
+
+ allMovies.appendChild(pElement);
+ pElement.innerHTML = quoteString;
+
+ // return pElement;
+ }
+ )
+ movieNumber.innerText = movies.length;
+}
+setTimeout(myMovies, 1000);
// create a new movie object for your favorite movie
+let newMovie = {
+ title: "Pursuit of happiness",
+ director: "Gabriele Muccino",
+ type: "drama",
+ haveWatched: true,
+ }
+
+
+// console.log(movies);
+
// create addMovies function
+function addMovies(movie){
+movies.push(movie);
+let deleteEl = allMovies.querySelectorAll("p");
+deleteEl.forEach((p, index) => index ? allMovies.removeChild(p): NaN);
+myMovies();
+}
+setTimeout(addMovies, 2000, newMovie)
+
+// var down = document.getElementById("btn");
+
+
+ // Create a break line element
+ var br = document.createElement("br");
+ function createForm() {
+var form = document.createElement("form");
+ form.setAttribute("method", "post");
+ form.setAttribute("action", "submit");
+
+ // Create an input element for title
+ var title = document.createElement("input");
+ title.setAttribute("type", "text");
+ title.setAttribute("name", "title");
+ title.setAttribute("placeholder", "title");
+ title.setAttribute("id", "title");
+
+ // Create an input element for director
+ var director = document.createElement("input");
+ director.setAttribute("type", "text");
+ director.setAttribute("name", "director");
+ director.setAttribute("placeholder", "director");
+ director.setAttribute("id", "director");
+
+ // Create an input element for type
+ var type = document.createElement("input");
+ type.setAttribute("type", "text");
+ type.setAttribute("name", "type");
+ type.setAttribute("placeholder", "type");
+ type.setAttribute("id", "type");
+
+ // Create an input element for haveWatched
+ var haveWatched = document.createElement("input");
+ haveWatched.setAttribute("type", "havewatched");
+ haveWatched.setAttribute("name", "havewatched");
+ haveWatched.setAttribute("placeholder", "havewatched");
+ haveWatched.setAttribute("id", "havewatched");
+
+ // create a submit button
+ var s = document.createElement("input");
+ s.setAttribute("type", "Submit");
+ s.setAttribute("value", "Submit");
+
+ // Append the title input to the form
+ form.appendChild(title);
+
+ // Inserting a line break
+ form.appendChild(br.cloneNode());
+
+ // Append the director to the form
+ form.appendChild(director);
+ form.appendChild(br.cloneNode());
+
+ // Append the type to the form
+ form.appendChild(type);
+ form.appendChild(br.cloneNode());
+
+ // Append the haveWatched to the form
+ form.appendChild(haveWatched);
+ form.appendChild(br.cloneNode());
+
+ // Append the submit button to the form
+ form.appendChild(s);
+
+ document.body.appendChild(form);
+
+ let btn = document.querySelector("input:last-of-type");
+ btn.addEventListener("click",(event) => {
+
+ event.preventDefault();
+ let title = document.getElementById("title");
+ let director = document.getElementById("director");
+ let type = document.getElementById("type");
+ let havewatched = document.getElementById("havewatched");
+
+ let myNewMovie = {
+ title: title.value,
+ director: director.value,
+ type: type.value,
+ haveWatched: havewatched.value
+ };
+ console.log(myNewMovie);
+ addMovies(myNewMovie);
+ });
+ }
+ createForm();
+
+ // let btn = document.querySelector("input:last-of-type");
+ // btn.addEventListener("click",(event) => {
+
+ // event.preventDefault();
+ // let title = document.getElementById("title");
+ // let director = document.getElementById("director");
+ // let type = document.getElementById("type");
+ // let havewatched = document.getElementById("havewatched");
+
+ // let myNewMovie = {
+ // title: title.value,
+ // director: director.value,
+ // type: type.value,
+ // haveWatched: havewatched.value
+ // };
+ // console.log(myNewMovie);
+ // addMovies(myNewMovie);
+ // })
+
+
+
diff --git a/Week-3/InClass/Callbacks/exercise-2/index.html b/Week-3/InClass/Callbacks/exercise-2/index.html
index bc9654c..40b1a3d 100644
--- a/Week-3/InClass/Callbacks/exercise-2/index.html
+++ b/Week-3/InClass/Callbacks/exercise-2/index.html
@@ -15,7 +15,7 @@
-
+alert
diff --git a/Week-3/InClass/DOM-practice/main.js b/Week-3/InClass/DOM-practice/main.js
index be9f609..8c29d66 100644
--- a/Week-3/InClass/DOM-practice/main.js
+++ b/Week-3/InClass/DOM-practice/main.js
@@ -2,11 +2,20 @@ console.log("Testing JS file loaded!")
// Task 1
-// Without changing any of the HTML or CSS, update the tags so that they have white backgrounds.
-
-
-
+// Without changing any of the HTML or CSS, update the tags so that they have white backgrounds.
+let mySection = document.getElementsByTagName("section")[0];
+console.log(mySection);
+mySection.style.backgroundColor = "white";
+console.log(mySection);
+let mySection1 = document.getElementsByTagName("section")[1];
+console.log(mySection1);
+mySection1.style.backgroundColor = "white";
+console.log(mySection1);
+let mySection2 = document.getElementsByTagName("section")[2];
+console.log(mySection2);
+mySection2.style.backgroundColor = "white";
+console.log(mySection2);
// Task 2
@@ -16,10 +25,39 @@ console.log("Testing JS file loaded!")
// Hint: look at the CSS to see if there are any classes already written which you can use.
+let myImg = document.getElementsByTagName("img")[0];
+myImg.style.display = "flex";
+myImg.style.margin = "0 auto";
+console.log(myImg);
+let myImg1 = document.getElementsByTagName("img")[1];
+myImg1.style.display = "flex";
+myImg1.style.margin = "0 auto";
+console.log(myImg1);
+let myImg2 = document.getElementsByTagName("img")[2];
+myImg2.style.display = "flex";
+myImg2.style.margin = "0 auto";
+console.log(myImg2);
// 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 .
+let myhEl = document.querySelectorAll("section")[0];
+let pEl = document.createElement("p");
+pEl.innerHTML = "Date of Birth: December 9, 1906"
+myhEl.appendChild(pEl);
+console.log(myhEl);
+
+let myEl = document.querySelectorAll("section")[1];
+let mypEl = document.createElement("p");
+mypEl.innerHTML = "Date of Birth: August 26, 1918"
+myEl.appendChild(mypEl);
+console.log(mypEl);
+
+let myEl2 = document.querySelectorAll("section")[2];
+let mypEl2 = document.createElement("p");
+mypEl2.innerHTML = "Date of Birth: 10 December 1815"
+myEl2.appendChild(mypEl2);
+console.log(mypEl2);