This repository was archived by the owner on Oct 26, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 453
Altom-week-9 #1032
Open
AltomHussain
wants to merge
1
commit into
CodeYourFuture:manchester3
Choose a base branch
from
AltomHussain:Altom-week-9
base: manchester3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Altom-week-9 #1032
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,8 @@ Take a look at the following code: | |
6 console.log(x); | ||
``` | ||
|
||
Explain why line 4 and line 6 output different numbers. | ||
Explain why line 4 and line 6 output different numbers? | ||
Because line 4 is global variable and line 6 is local variable | ||
|
||
## Question 2 | ||
|
||
|
@@ -34,6 +35,8 @@ console.log(y) | |
|
||
What will be the output of this code. Explain your answer in 50 words or less. | ||
|
||
The output will 10 for the console.log of x and and undefined because of the y is not defined outside the function f1() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct! You missed an explanation of |
||
|
||
## Question 3 | ||
|
||
Take a look at the following code: | ||
|
@@ -61,3 +64,6 @@ console.log(y); | |
``` | ||
|
||
What will be the output of this code. Explain your answer in 50 words or less. | ||
|
||
The console.log of x will be 9 and the f1() will not give any output because we did not console.log it. | ||
The console.log of y will be { x: 9 } and the f2() will not give any output because we did not console.log it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct :) well done! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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"); | ||
let temperatureSection = document.querySelector(".temperature"); | ||
let temperatureSpan = document.querySelector(".temperature span"); | ||
console.log(temperatureSpan); | ||
if (navigator.geolocation) { | ||
navigator.geolocation.getCurrentPosition((position) => { | ||
long = position.coords.longitude; | ||
lat = position.coords.latitude; | ||
const proxy = "https://cors-anywhere.herokuapp.com/"; | ||
const url = `${proxy}https://api.darksky.net/forecast/fd9d9c6418c23d94745b836767721ad1/${lat},${long}`; | ||
fetch(url) | ||
.then((response) => { | ||
return response.json(); | ||
}) | ||
.then((data) => { | ||
console.log(data); | ||
const { temperature, summary, icon } = data.currently; | ||
// set dom elements from API | ||
temperatureDegree.textContent = temperature; | ||
temperatureDescription.textContent = summary; | ||
locationTimeZone.textContent = data.timezone; | ||
//Formula for Celsius | ||
let celsius = (temperature - 32) * (5 / 9); | ||
|
||
///Set Icon | ||
setIcons(icon, document.querySelector(".icon")); | ||
////// change temperature to Celsius/Fahrenheit | ||
temperatureSection.addEventListener("click", function () { | ||
if (temperatureSpan.textContent === "F°") { | ||
temperatureSpan.textContent = "C"; | ||
temperatureDegree.textContent = Math.floor(celsius); | ||
} else { | ||
temperatureSpan.textContent = "F°"; | ||
temperatureDegree.textContent = temperature; | ||
} | ||
}); | ||
}) | ||
|
||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
}); | ||
} | ||
function setIcons(icon, iconID) { | ||
const skycons = new Skycons({ color: "white" }); | ||
const currentIcon = icon.replace(/-/g, "_").toUpperCase(); | ||
skycons.play(); | ||
return skycons.set(iconID, Skycons[currentIcon]); | ||
} | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link href="style.css" rel="stylesheet" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div class="location"> | ||
<h1 class="location-timezone">TimeZone</h1> | ||
<canvas class="icon" width="128" height="128"></canvas> | ||
</div> | ||
<div class="temperature"> | ||
<div class="degree-section"> | ||
<h2 class="temperature-degree">34</h2> | ||
<span>F°</span> | ||
</div> | ||
<div class="temperature-description">It is very cold</div> | ||
</div> | ||
<script src="skycons.js"></script> | ||
<script src="exercise.js"></script> | ||
</body> | ||
</html> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other way around, line 4 is local and line 6 is global :)