Last active
February 15, 2018 15:52
-
-
Save kowsheek/86685fc36d143941e2b41265ee7cc59b to your computer and use it in GitHub Desktop.
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 sum(x, y) { | |
return (x + y); | |
} | |
console.log('sum', sum(10, 20)); |
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 addsFive(x) { | |
function a(y) { | |
return (x + y) + 5; | |
}; | |
function b(z) { | |
return (x + z) + 5; | |
}; | |
return a(10) + b(20); | |
} | |
var result = addsFive(30); | |
console.log(result); |
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 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); |
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 welcome(firstName, lastName) { | |
function addHello(firstName) { | |
return 'Hello ' + firstName + '!\n'; | |
}; | |
function addWelcome(area) { | |
return 'Welcome to ' + area + '.'; | |
}; | |
return function(area) { | |
return addHello(firstName) + addWelcome(area); | |
}; | |
} | |
var welcoming = welcome('Jack', 'Belly'); | |
console.log(welcoming('Toronto')); | |
console.log('\n'); | |
console.log(welcoming('Montreal')); | |
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 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)); |
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. 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment