This file contains hidden or 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
// Implement a decorator function that takes | |
// a function as an argument and will track | |
// how many times the passed function was called. | |
function Add(x, y) { | |
return x + y; | |
} | |
var addCallCount = countDecorator(Add); |
This file contains hidden or 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
// Given the following data structure | |
// implement a oldestLivingFather method | |
// that will return the name of the oldest | |
// living father. | |
var people = [ | |
{ | |
name: 'Hank', | |
age: 29, | |
father: 'Don' |
This file contains hidden or 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
// Using a ternary operator. Implement an exclusive OR function called `preferredName` that has the following interface: | |
var FirstName, | |
LastName; | |
preferredName(FirstName, LastName); | |
// -> false | |
FirstName = 'Hank'; |