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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> |
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
* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 50px 20px; | |
} | |
.error-report { | |
color: red; |
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
function accessFirstItem(array) { | |
return array[0]; | |
} | |
function accessThirdItem(array) { | |
return array[2]; | |
} | |
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
// noprotect | |
// ^^ `noprotect` is here to prevent a bug with jsbin and for loops. | |
function average(numbers) { | |
numTotal = 0; | |
for (var i=0; i < numbers.length; i++) { | |
numTotal+= numbers[i]; | |
} | |
return (numTotal)/numbers.length; | |
} |
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. | |
Scope determines how you access variables created in JavaSctip. JavaScript has two types of scopes: global and local. | |
A variable created with global scope, known as a "Global," is accessible everywhere, even across files. | |
Every variable declared outside of a function in JavaSctip has global scope. A variable with local scope is only accessible | |
within the function block it was created in. It lives and dies within the function it was created in. When the function is finished, | |
the new variable disappears. | |
Why are global variables avoided? | |
Globals are avoided because they can create unintentional side effects and can make functions indeterminate. It can make things go wrong, | |
and then also be hard to debug. However, it is OK to use global variables when using a JavaScript Library like JQuery. |
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
function keyDeleter(obj) { | |
delete obj.foo; | |
delete obj.bar; | |
return obj; | |
} | |
var sampleObj = { | |
foo: 'foo', | |
bar: 'bar', |
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
var studentData = [ | |
{ | |
name: 'Tim', | |
status: 'Current student', | |
course: 'Biology' | |
}, | |
{ | |
name: 'Sue', | |
status: 'Withdrawn', | |
course: 'Mathematics' |
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
function getTokens(rawString) { | |
// NB: `.filter(Boolean)` removes any falsy items from an array | |
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort(); | |
} | |
function mostFrequentWord(text) { | |
//pulling each word out of the array of text | |
var words = getTokens(text); | |
//creating and empty variable | |
var wordFrequencies = {}; |
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
// where I started. . . | |
// $(function(){ | |
// $(".thumbnail").click(function(event) { | |
// $(".hero").replaceWith($(this)); | |
// }); | |
// }); | |
// where I shifted, but couldn't figure out who to identify the src of the clicked image | |
// $(function(){ | |
// $(".thumbnail").click(function(event) { |
OlderNewer