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/qaluneq/edit?html,js,console,output |
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
/* GET TOKENS: this function takes a 'raw string' and 'gets'/organizes every | |
character and word in 'alphabetical order' inside of an array. each of the words | |
and chars which were once part of a single string have now been given their own | |
index positions */ | |
function getTokens(rawString) { | |
// NB: `.filter(Boolean)` removes any falsy items from an array | |
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort(); | |
} | |
// mostFrequentWord is a function that takes a string of text as its argument |
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
.map: | |
https://jsbin.com/yowisob/edit?js | |
for loop: | |
https://jsbin.com/yowisob/edit?js |
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/wiruzez/edit?js |
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
Scope refers to the regions of your code in which your variables can be accessed. If a variable is within | |
the global scope, it means that it can be accessed from any other place in your program. If a variable is | |
local to a function, that means that it can only be accessed by the code inside the block of that function. | |
Global variables are avoided because they can cause all kind of unintended side effects. These side | |
effects can cause parts of your program to produce different results when given the exact same inputs, | |
which is obviously not a good thing. | |
Strict mode forces the user to be more careful with their syntax by throwing errors where the code | |
would normally just run. Things such as: if a function parameter name were not unique within whole of the |
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/bumocas/edit?js |
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/bicegoh/edit?js |
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/jekunet/edit?js,console,output |
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
// Area of a Rectangle | |
function computeArea(width, height) { | |
return width * height; | |
} | |
function testComputeArea() { | |
var width = 3; | |
var height = 4; | |
var expected = 12; |