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 wisePerson(wiseType, whatToSay) { | |
return 'A wise ' + wiseType + ' once said: "' + whatToSay + '".'; | |
} | |
/* 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 wisePerson(wiseType, whatToSay) { | |
return 'A wise ' + wiseType + ' once said: "' + whatToSay + '".'; | |
} | |
/* 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; | |
} | |
/* 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 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
function max(numbers) { | |
var currentMax = numbers[0]; | |
for (var i=0; i <= numbers.length; i++) { | |
if (numbers[i] > currentMax) { | |
currentMax = numbers[i]; | |
} | |
} | |
return currentMax; | |
} |
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 is a term used to classify parts of your code that have access to a variable. If the scope of the variable is local, any code inside the function can access the variable. Any code outside the function cannot. If the scope of a variabel is global, it means that the variable can be accessed from anywhere. | |
Why are global variables avoided? | |
Global variables can be bad for a variety of reasons- they make it difficult to work collaboratively, they can lead to bugs in your code that are difficult to untangle, you can run into concurrency issues, you may confuse global and local variable names, and so on. | |
Explain JavaScript's strict mode | |
JS's strict mode disables the use of global variables, forcing the user to define all variables locally. | |
What are side effects, and what is a pure function? |
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 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
function mergeDataStreams(stream1, stream2) { | |
var results = {}; | |
for (var i=0; i < stream1.length; i++) { | |
results[stream1[i].id] = stream1[i]; | |
} | |
for (var key in results) { | |
var otherData = stream2.find( | |
function(item) { return item.id === key; }); | |
for (var _key in otherData) { |
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 getDataFromApi(callback) { | |
var settings = { | |
url: "https://api.github.com/gists/public", | |
dataType: 'json', | |
type: 'GET', | |
success: callback | |
}; | |
$.ajax(settings); | |
} |
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
app.get('/test', function (req, res) { | |
res.send('Now viewing the test page') | |
}) |
OlderNewer