Skip to content

Instantly share code, notes, and snippets.

@DominicTremblay
Forked from kowsheek/W1D2 breakout outline
Created January 17, 2018 14:11
Show Gist options
  • Save DominicTremblay/3e23574cdd056bbe0b2557aa7fe9b010 to your computer and use it in GitHub Desktop.
Save DominicTremblay/3e23574cdd056bbe0b2557aa7fe9b010 to your computer and use it in GitHub Desktop.
function sum(x, y) {
return (x + y);
}
console.log('sum', sum(10, 20));
function sum(x, y, callback) {
var sum = x + y;
if (callback) {
callback(sum);
}
}
function logger1(s) {
console.log('logger 1: ', s);
}
function logger2(s) {
console.log('logger 2: ', s);
}
sum(10, 20, logger2);
function addsFive(x) {
return function (y) {
return (x + y) + 5;
};
}
var first = addsFive(10);
console.log(first.toString());
var second = first(20, 40);
console.log(second);
function sum(x, y) {
return (x + y);
}
function multiply(x, y) {
var mySum = 0;
for (var i = 0; i < x; i++) {
mySum = sum(y, y);
}
console.log(mySum);
return (x * y);
}
console.log('sum', sum(10, 20));
console.log('multiply', multiply(10, 20));
1. Reading code
- Instructions
- Inputs
- Variables
- Outputs
2. Scopes
- Global scope
- Local scope
- Chaining scopes
3. Functions
- The nature of functions
- Basics of functions
- Nesting functions
- Callback functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment