This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 458
shahd-week-9 #1029
Open
shahdalhaj
wants to merge
1
commit into
CodeYourFuture:manchester3
Choose a base branch
from
shahdalhaj:shahd-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
shahd-week-9 #1029
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 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 |
---|---|---|
|
@@ -14,7 +14,7 @@ Take a look at the following code: | |
``` | ||
|
||
Explain why line 4 and line 6 output different numbers. | ||
|
||
line 4 log x=2 as it's been defined as a local variable inside the curly brakets, line 6 log x=1 for the global variable that has been defiend in line 1 | ||
## Question 2 | ||
|
||
Take a look at the following code: | ||
|
@@ -33,6 +33,7 @@ console.log(y) | |
``` | ||
|
||
What will be the output of this code. Explain your answer in 50 words or less. | ||
for the first log in line 27 the output should be 10 for the global variable x, line 31 output will be undefiend the function call is empty no thing has been passed to the function to process, line 32 log undefined since y has been defiend locally inside 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. Close :) Line 31 output will be undefined because nothing is being returned from the function. |
||
|
||
## Question 3 | ||
|
||
|
@@ -46,18 +47,18 @@ function f1(val) { | |
return val; | ||
} | ||
|
||
f1(x); | ||
console.log(x); | ||
f1(x); this line will pass x value(10) to the function the out put for it will be 10 and it's going to be returned and not logged to the console. | ||
console.log(x); this line will log 9 the value of the global variable x; | ||
|
||
const y = { x: 9 }; | ||
const y = { x: 9 }; we have the object y | ||
|
||
function f2(val) { | ||
val.x = val.x + 1; | ||
return val; | ||
} | ||
|
||
f2(y); | ||
console.log(y); | ||
f2(y); the output for this line should be 10 and the value is returned and not logged to the console; | ||
console.log(y); it will log the object y ===> {x:9} | ||
``` | ||
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. Both correct :) |
||
|
||
What will be the output of this code. Explain your answer in 50 words or less. |
This file contains 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,27 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel = 'stylesheet' href="./style.css" /> | ||
<title>Wheather app</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">0.0</h2> | ||
<span>F°</span> | ||
</div> | ||
<div class="temperatur-description">Status</div> | ||
</div> | ||
|
||
|
||
<script src="script2.js"></script> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains 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,52 @@ | ||
window.addEventListener('load', ()=> { | ||
let long; | ||
let lat; | ||
let temperatureDescription = document.querySelector('.temperatur-description') | ||
let temperatureDegree = document.querySelector('.temperature-degree') | ||
let locationTimezone = document.querySelector('.location-timezone') | ||
let temperatureSection = document.querySelector('.temperature') | ||
let temperaturSpan = document.querySelector('.temperature span') | ||
|
||
if(navigator.geolocation){ | ||
navigator.geolocation.getCurrentPosition(positon => { | ||
long = positon.coords.longitude | ||
lat =positon.coords.latitude | ||
const proxy = " https://cors-anywhere.herokuapp.com/" | ||
const api = `${proxy}https://api.darksky.net/forecast/fd9d9c6418c23d94745b836767721ad1/${lat},${long}` | ||
|
||
fetch(api) | ||
.then(data => data.json()) | ||
.then(data=> { | ||
console.log(data) | ||
const {temperature, summary, icon} = data.currently | ||
//Set DOM Elements form the api | ||
temperatureDegree.textContent = temperature | ||
temperatureDescription.textContent = summary | ||
locationTimezone.textContent = data.timezone | ||
|
||
//formula for celsius | ||
let celsius = (temperature - 32) * (5/9) | ||
//Set Icons | ||
setIcons(icon, document.querySelector('.icon')) | ||
|
||
//Set degree to celsius/ Fahrenheit | ||
temperatureSection.addEventListener('click', ()=>{ | ||
if(temperaturSpan.textContent === 'F°'){ | ||
temperaturSpan.textContent = 'C°' | ||
temperatureDegree.textContent = Math.floor(celsius) | ||
} else { | ||
temperaturSpan.textContent = 'F°' | ||
temperatureDegree.textContent = temperature | ||
} | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
function setIcons (icon, iconID){ | ||
const skycons = new Skycons({color: 'white'}) | ||
const currentIcon = icon.replace(/-/g, '_').toUpperCase(); | ||
skycons.play(); | ||
return skycons.set(iconID, Skycons[currentIcon]) | ||
} | ||
}) |
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.
Correct! :)