diff --git a/week-2/Homework/mandatory/4-programmer-humour/index.html b/week-2/Homework/mandatory/4-programmer-humour/index.html
new file mode 100644
index 0000000..e69de29
diff --git a/week-2/Homework/mandatory/4-programmer-humour/script.js b/week-2/Homework/mandatory/4-programmer-humour/script.js
new file mode 100644
index 0000000..e69de29
diff --git a/week-3/Homework/mandatory/1-practice/2-code-reading.md b/week-3/Homework/mandatory/1-practice/2-code-reading.md
index 295964e..8bbf043 100644
--- a/week-3/Homework/mandatory/1-practice/2-code-reading.md
+++ b/week-3/Homework/mandatory/1-practice/2-code-reading.md
@@ -15,6 +15,8 @@ Take a look at the following code:
Explain why line 4 and line 6 output different numbers.
+// Because of scope, first x in the global scope , after that second x inside local scop.
+
## Question 2
Take a look at the following code:
@@ -34,6 +36,8 @@ console.log(y)
What will be the output of this code. Explain your answer in 50 words or less.
+// it will log 10 for x .But it will give an error that y is not defined .. because the log for y made out of side the scope the y have been defined in .. (let inside the block scoped)
+
## Question 3
Take a look at the following code:
@@ -60,4 +64,6 @@ f2(y);
console.log(y);
```
-What will be the output of this code. Explain your answer in 50 words or less.
+What will be the output of this code. Explain your answer in 50 words or less
+
+//It will log 9 and x =10 and because x defined with const and const can not be reassigned (constant) the same applied for the const object if we reassigned the object or we attempted to overwrite it, but the keys for that object are not protected so we can reassign them or overwrite them.
\ No newline at end of file
diff --git a/week-3/Homework/mandatory/1-practice/app.css b/week-3/Homework/mandatory/1-practice/app.css
new file mode 100644
index 0000000..3fcb71c
--- /dev/null
+++ b/week-3/Homework/mandatory/1-practice/app.css
@@ -0,0 +1,37 @@
+*{
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+}
+body{
+ height: 100vh;
+ display: flex;
+ justify-content: center;
+ flex-direction: column;
+ align-items: center;
+ background: linear-gradient(rgb(47,150,163),rgb(48,62,143));
+ font-family: sans-serif;
+ color: white;
+}
+.location,.temperature{
+ height: 30vh;
+ width: 50%;
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+}
+.temperature{
+ flex-direction: column;
+}
+.degree-section{
+ display: flex;
+ align-items: center;
+ cursor: pointer;
+}
+.degree-section span{
+ margin: 10px;
+ font-size: 30px;
+}
+.degree-section h2{
+ font-size: 40px;
+}
diff --git a/week-3/Homework/mandatory/1-practice/app.html b/week-3/Homework/mandatory/1-practice/app.html
new file mode 100644
index 0000000..b35320b
--- /dev/null
+++ b/week-3/Homework/mandatory/1-practice/app.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+ Weather
+
+
+
+
+
TimeZone
+
+
+
+
+
34
+F
+
+
Its frozen cold
+
+
+
+
+
\ No newline at end of file
diff --git a/week-3/Homework/mandatory/1-practice/app.js b/week-3/Homework/mandatory/1-practice/app.js
new file mode 100644
index 0000000..f538b07
--- /dev/null
+++ b/week-3/Homework/mandatory/1-practice/app.js
@@ -0,0 +1,85 @@
+window.addEventListener('load', ()=>{
+ let long;
+ let lat;
+ let temperatureDescription = document.querySelector('.temperature-description');
+ let temperatureDegree = document.querySelector('.temperature-degree');
+ let locationTimeZone = document.querySelector('.location-timezone');
+ if(navigator.geolocation){
+ navigator.geolocation.getCurrentPosition(position =>{
+ long=position.coords.longitude;
+ lat=position.coords.latitude;
+
+ const proxy = "https://cors-anywhere.herokuapp.com/";
+ const api = `${proxy}https://api.darksky.net/forecast/fd9d9c6418c23d94745b836767721ad1/${lat},${long}`;
+
+ fetch(api)
+ .then(response =>{
+ return response.json();
+ })
+ .then(data =>{
+ console.log(data)
+ const {temperature,summary, icon}= data.currently;
+ //set Dom Elements from the API
+ temperatureDegree.textContent = temperature;
+ temperatureDescription.textContent = summary;
+ locationTimeZone.textContent = data.timezone;
+ //set Icon
+ setIcons(icon,document.querySelector('.icon'));
+ });
+
+ });
+
+ }
+
+ function setIcons(icon,iconID){
+ const skycons = new Skycons({color:'white'});
+ const currentIcon = icon.replace(/-/g, "_").toUpperCase();
+ skycons.play();
+ return skycons.set(iconID,Skycons[currentIcon]);
+ }
+
+ });
+//Formula For CELSIUS
+let celsius = (temperature - 32) * (5 / 9);
+//set Icon
+setIcons(icon,document.querySelector('.icon'));
+
+
+//change teperature to celsius/farenheit
+temperatureSection.addEventListener('click',()=>{
+ if(temperatureSpan.textContent === 'F'){
+ temperatureSpan.textContent = 'C';
+ temperatureDegree.textContent = Math.floor(celsius);
+ }else{
+ temperatureSpan.textContent = 'F';
+ temperatureDegree.textContent = temperature;
+ }
+});
+
+
+
+const proxy = "https://cors-anywhere.herokuapp.com/";
+const api = `${proxy}https://api.darksky.net/forecast/fd9d9c6418c23d94745b836767721ad1/${lat},${long}`;
+
+fetch(api)
+.then(response =>{
+ return response.json();
+})
+.then(data =>{
+console.log(data)
+ const {temperature,summary, icon}= data.currently;
+//set Dom Elements from the API
+temperatureDegree.textContent = temperature;
+temperatureDescription.textContent = summary;
+locationTimeZone.textContent = data.timezone;
+//set Icon
+setIcons(icon,document.querySelector('.icon'));
+});
+
+
+function setIcons(icon,iconID){
+const skycons = new Skycons({color:'white'});
+const currentIcon = icon.replace(/-/g, "_").toUpperCase();
+skycons.play();
+return skycons.set(iconID,Skycons[currentIcon]);
+}
\ No newline at end of file
diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js
index 10b93ba..581876e 100644
--- a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js
+++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js
@@ -4,8 +4,10 @@ const personOne = {
favouriteFood: 'Spinach'
}
-function introduceYourself(___________________________) {
- console.log (`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`);
+let{name,age,favouriteFood} = personOne;
+
+function introduceYourself(x) {
+ console.log (`Hello, my name is ${x.name}. I am ${x.age} years old and my favourite food is ${x.favouriteFood}.`);
}
introduceYourself(personOne);
\ No newline at end of file
diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js
index 0d3ade0..a71df4e 100644
--- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js
+++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js
@@ -9,3 +9,13 @@ let hogwarts = [
{ firstName: "Minerva", lastName: "McGonagall", house: "Gryffindor", pet: null, occupation: "Teacher" },
{ firstName: "Albus", lastName: "Dumbledore", house: "Gryffindor", pet: "Phoenix", occupation: "Teacher" }
]
+
+ //Alternative way
+// let griF = hogwarts.filter(x => x.house ==="Gryffindor").map(x => x.firstName+x.lastName).toString();
+// console.log(griF);
+function GryffindorPeople([Harry,Hermione, , , , , ,Minerva,Albus]){
+ console.log(Harry.firstName,Harry.lastName,Hermione.firstName,Hermione.lastName,Minerva.firstName,Minerva.lastName,Albus.firstName,Albus.lastName);
+}
+
+GryffindorPeople(hogwarts);
+//let[firstName,lastName,...rest] = hogwarts;
diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js
index b60d527..eea03d7 100644
--- a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js
+++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js
@@ -2,8 +2,32 @@
{ itemName: "Hot cakes", quantity: 1, unitPrice: 2.29},
{ itemName: "Apple Pie", quantity: 2, unitPrice: 1.39},
{ itemName: "Egg McMuffin", quantity: 1, unitPrice: 2.80},
- { itemName: "Sausage McMuffin", quantity: 1, unitPrice: 3.00},
+ { itemName: "Ssge McMuffin", quantity: 1, unitPrice: 3.00},
{ itemName: "Hot Coffee", quantity: 2, unitPrice: 1.00},
{ itemName: "Hash Brown", quantity: 4, unitPrice: 0.40}
]
-
\ No newline at end of file
+
+
+ //let[...rest]= order;
+ //console.log(rest[0]);
+
+
+
+ function findTotal([...rest]){
+ let plus = 0;
+
+ for(let i=0;i