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
| function Penguin(name) { | |
| this.name = name; | |
| this.numLegs = 2; | |
| } | |
| function Emperor(name) { | |
| this.name = name; | |
| }; | |
| Emperor.prototype = new Penguin(); |
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
| // first // | |
| _.first = function(array) { | |
| return array[0]; | |
| } | |
| // | |
| _.first = function(array, [i]) { | |
| return array[i]; | |
| } |
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
| // first // | |
| _.first = function(array) { | |
| return array[0]; | |
| } | |
| // first with [i] // | |
| _.first = function(array, [i]) { | |
| return array[i]; | |
| } |
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
| var _ = {}; | |
| //last element// | |
| _.last = function(array) { | |
| var index = array.length-1; | |
| return array[index]; | |
| } | |
| //last i elements// | |
| _.last = function(array, i) { |
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
| var _ = {}; | |
| _.every = function(list, condition) { | |
| for (var i = 0; i<list.length; i++) { | |
| if (!condition(list[i])) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } |
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
| var _ = {}; | |
| _.filter = function(list, condition) { | |
| var resultArray = []; | |
| for (var i = 0; i<list.length; i++) { | |
| if (condition(list[i])) { | |
| resultArray.push(list[i]); | |
| } | |
| } | |
| return resultArray; |
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
| var _ = {}; | |
| _.reject = function(list, condition) { | |
| var resultArray = []; | |
| for (var i = 0; i<list.length; i++) { | |
| if (!condition(list[i])) { | |
| resultArray.push(list[i]); | |
| } | |
| } | |
| return resultArray; |
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
| var _ = {}; | |
| _.some = function(list) { | |
| for (var i = 0; i<list.length; i++) { | |
| if (list[i]) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } |
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
| var _ = {}; | |
| _.contains = function(list, value) { | |
| for (var i = 0; i<list.length; i++) { | |
| if (list[i] === value) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } |
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
| var _ = {}; | |
| _.find = function(list, condition) { | |
| var resultArray = []; | |
| for (var i = 0; i<list.length; i++) { | |
| if (condition(list[i])) { | |
| resultArray.push(list[i]); | |
| } | |
| } | |
| if (resultArray.length) { |
OlderNewer