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
What is scope? Your explanation should include the idea of global vs. local scope. | |
With variables, there are two types: global and local. A global scope is a variable that is declared in the main body source of your code. | |
For example, imagine you have an JS file that has a variable declared *before* there is a function. Your global scope | |
would look like this: var schoolName="Island"; A local scope is a variable that has been declared and is *only* accessible through a set of | |
instructions, such a function. For example, if you were to have a JS file, and in this JS file there is a function called "mySchool." | |
Then your local scope in your JS file would look like this: function mySchool() | |
var schoolNames="Island"; | |
Why are global variables avoided? | |
Global variables are avoided because they can make your code extremely messy. Global variable or scope that is declared can be available |
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
//object creator | |
function createMyObject () { | |
return { | |
foo: 'bar', | |
answerToUniverse:42, | |
'olly olly': 'oxen free', | |
sayHello: function () { | |
return ('hello'); | |
} | |
} |
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
//thinkful notes with pedro dec.8.16 | |
function mostFrequentWord(words) { | |
// count = {}; | |
// count['apple'] = 1; | |
// count['apple'] = 3; | |
// count['apple'] = count['apple'] + 3; | |
// This would give me an object like: | |
// var count = { | |
// apple: 6 |
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
//most frequent word | |
function mostFrequentWord(words) { | |
var count = { | |
orange:1, | |
apple:3, | |
kiwi:2 | |
var biggestWord = ""; | |
var biggestCount=0; | |
object.jetys(count).forEach( |
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
//word counter drill | |
function wordCounter(word_list) { | |
} | |
// Should return { apple: 3, orange: 1 } | |
wordCounter(['apple', 'apple', 'apple', 'orange']); | |
function wordCounter(word_list){ | |
var fruit = {}; |
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
EXAMPLE PROBLEM W/MICHAEL | |
//var number_list = [1,3,6,6,7,8,2] | |
function problem(number_list){ | |
//var number_list = [4,6,10,12] | |
var sum_counter = 0 | |
for(var i = 0; i <number_list.length; i++) { | |
var value = number_list[i] | |
sum_counter = value + sum_counter |
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
1.)make student report | |
function makeStudentsReport(data) {//function name w/ argument | |
var answers = [];//create an empty array | |
for (var i=0; i<data.length; i++) {//for loop that measures length | |
var reports = data[i];//create another variable that has the argument | |
//inputting the for loop variable? | |
answers.length(reports.name + reports.grade);//ask the computer to | |
//print the length of the answers | |
} | |
return answers;//returning the array with proper information |
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
1.) Link Here, Link There | |
<main> | |
<h2>1. Open this Link THERE!</h2> | |
<p><a href = "#" target="https://www.stackoverflow.com">Stack Overflow </a></p> | |
--> Replace this text with a link that links to the Stack Overflow website and opens in a new tab. | |
<h2>2. Click a link to send email!</h2> | |
<p> <a href= "mailto:username@site.org?subject=link%20here%20link%20there%20linkhere,linkthere">Blank Email</a></p> | |
</main> | |
---> Replace the text in this paragraph that opens a blank email with the subject line, link here, link there |
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
1.) Drill 1: Width, Height, Color, Border | |
In this drill, you’ll add classes to the two divs to create a blue box and a red box, as described in the code comments and paragraphs in the code pen. To complete this drill, you'll need to use the following CSS properties: | |
background-color | |
margin-bottom | |
border | |
SOLUTION: | |
html | |
<main> |
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
1.) To complete the drill for element selectors below, you'll need to target section elements and h1 elements. Specifically: | |
Write one ruleset for sections that gives them a bottom margin of 90px | |
Write one ruleset for header elements that sets font-family to Helvetica. | |
HTML: | |
<main> | |
<section> | |
<header> | |
<h1>Really important section header</h1> |
OlderNewer