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> | |
<script id="jsbin-javascript"> |
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 shouter(whatToShout) { | |
return whatToShout.toUpperCase() + '!!!'; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! |
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 computeArea(width, height) { | |
return width*height; | |
} | |
// tests | |
function testComputeArea() { | |
var width = 3; | |
var height = 4; | |
var expected = 12; |
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 main() { | |
try { | |
doAllTheThings(); | |
} | |
catch(e) { | |
console.error(e) | |
reportError(e); | |
} | |
} |
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
https://jsbin.com/batotex/1/edit?js,console | |
https://jsbin.com/jazemoh/1/edit?js,console | |
https://jsbin.com/nunojug/1/edit?js,console | |
https://jsbin.com/geyuyek/1/edit?js,console | |
https://jsbin.com/calogo/1/edit?js,console | |
https://jsbin.com/gemexah/edit?js,console | |
https://jsbin.com/lixoqim/1/edit?js,console | |
https://jsbin.com/kuqosim/1/edit?js,console | |
https://jsbin.com/nezazu/1/edit?js,console | |
https://jsbin.com/juhojo/1/edit?js,console |
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
https://jsbin.com/sekihux/2/edit?js,output | |
https://jsbin.com/tevuri/2/edit?js,console | |
https://jsbin.com/mokuci/edit?js,console |
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. What is scope? Your explanation should include the idea of global vs. local scope. | |
- Scope is the way the the browser parses the information on the page. It is like a backward ladder that first looks | |
within the function, then steps back and looks within the parent, etc. | |
- global scope is a variable that is defined within the body or outside of a function and is then avaiable everywhere | |
within your site | |
- local scope is a variable defined within that current function. This can be the same variable from the body, but is | |
only relevent to that current function | |
2. Why are global variables avoided? | |
- Global variables should be avoided so that no unintended side effects happen within the code. This makes it available | |
everywhere in the code, which then becomes a bit difficult to maintain. |
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
https://jsbin.com/qaloxo/1/edit?js,console | |
https://jsbin.com/kokidav/edit?js,console | |
https://jsbin.com/fiwevut/1/edit?html,js,output | |
https://jsbin.com/dejiyo/1/edit?js,console |
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(); | |
/*returns a raw string, converts to lower case, splots the words/letters | |
by the user of spaces, commas, exclamation points, periods quotes, | |
semicolons, colons, hyphens and sort them in alphabetical order after | |
finding out if it is true or not*/ | |
} | |
function mostFrequentWord(text) { |
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
https://jsbin.com/walejod/edit?js,console | |
https://jsbin.com/deworib/3/edit?js,console | |
https://jsbin.com/qijepap/1/edit?js,console -- no idea what I was supposed to be finding for this one. need help talking this one out. | |
https://jsbin.com/borecug/edit?js,console -- even when running this one which i copied and pasted from the solution i still get an error | |
github: https://github.com/michaelablackham/thinkful-object-drills-2 |
OlderNewer