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 textNormalizer(text) { | |
return `${text.toLowerCase().trim()}` | |
} | |
function shouter(whatToShout) { | |
return `${whatToShout.toUpperCase()}!!!`; | |
} | |
function wisePerson(wiseType, whatToSay) { | |
return `A wise ${wiseType} once said: "${whatToSay}".`; |
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; | |
} | |
function celsToFahr(celsTemp) { | |
return celsTemp * 1.8 + 32; | |
} | |
function fahrToCels(fahrTemp) { | |
return (fahrTemp - 32) * 1.8; |
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 doTrafficLights() { | |
const activeLight = getActiveLight(); | |
if (activeLight === 'red') { | |
turnRed() | |
} else if (activeLight ==="green") { | |
turnGreen() | |
} else { | |
turnYellow() | |
} | |
} |
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
Creating arrays | |
function makeList(item1, item2, item3) { | |
return [item1, item2, item3] | |
} | |
Adding array items | |
function addToList(list, item) { | |
list.push(item); |
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
Array copying I | |
function firstFourItems(array) { | |
return array.slice(0, 4) | |
} | |
function lastThreeItems(array) { | |
return array.slice(-3) | |
} |
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
max and min (without sort) | |
function max(numbers) { | |
maxNumber = numbers[0]; | |
for (let i = 0; i < numbers.length; i++) { | |
if (maxNumber < numbers[i]) { | |
maxNumber = numbers[i]; | |
} | |
} | |
return maxNumber |
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 refers to the boundaries in which a variable or constant will interact with functions in code. | |
A variable has global scope when it is defined outside of a function. Global variables will be recognized | |
by functions throughout a folder of JS files. | |
A variable has local scope when it is defined within a function. A local variable is only recognized | |
within its function. | |
Why are global variables avoided? | |
As an app becomes more complex and requires many functions, global variables can cause there to be bugs | |
which are difficult to find. For example, if a global variable is defined in one JS file and altered in a function in another JS File in another, |
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(key1, key2, key3, key4) { | |
obj = { | |
foo: 'bar', | |
answerToUniverse: 42, | |
'olly olly': 'oxen free', | |
sayHello: function sayHello() { | |
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
Make student reports: https://repl.it/@Stephaniejoy/Make-student-reports-drill | |
Enroll in summer school: https://repl.it/@Stephaniejoy/Enroll-in-summer-school-drill | |
Find by id: https://repl.it/@Stephaniejoy/find-by-id-drill | |
Validate object keys: https://repl.it/@Stephaniejoy/validate-object-keys-drill |
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
Commented code: https://repl.it/@Stephaniejoy/most-frequent-word-analyzer-challenge |
OlderNewer