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
'use strict'; | |
Array.prototype.reduce = function(callback, initialValue) { | |
let counter; | |
let accumulatedValue; | |
if (this.length === 0) { | |
return this; | |
} else { | |
if (arguments.length === 1) { |
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
'use strict'; | |
function reduce() { | |
var boxarts = [{ | |
width: 200, | |
height: 200 | |
}, { | |
width: 150, | |
height: 200 | |
}, { |
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
'use strict'; | |
Array.prototype.concatAll = function() { | |
var results = []; | |
this.forEach(function(subArray) { | |
if (Array.isArray(subArray)) | |
subArray.forEach((item) => results.push(item)) | |
else | |
throw new Error('Its not two dimensional array;'); | |
}); |
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
'use strict'; | |
function queryNestedArray() { | |
var movieLists = [{ | |
name: "New Releases", | |
videos: [{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"rating": 4.0 | |
}, { |
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
'use strict'; | |
function chain() { | |
var newReleases = [{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"rating": 4.0 | |
}, { | |
"id": 654356453, | |
"title": "Bad Boys", |
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
'use strict'; | |
function predicate() { | |
var newReleases = [{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"rating": 4.0 | |
}, { | |
"id": 654356453, | |
"title": "Bad Boys", |
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
'use strict'; | |
Array.prototype.filter = function(Predicate) { | |
var result = []; | |
this.forEach(function(itemInArray) { | |
Predicate(itemInArray) ? result.push(itemInArray) : null; | |
}); | |
return result; |
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
'use strict'; | |
function predicate() { | |
var newReleases = [{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"rating": 4.0 | |
}, { | |
"id": 654356453, | |
"title": "Bad Boys", |
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
'use strict'; | |
function projection() { | |
var newReleases = [{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"rating": [4.0] | |
}, { | |
"id": 654356453, | |
"title": "Bad Boys", |
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
'use strict'; | |
Array.prototype.map = function(projectionFunction) { | |
var results = []; | |
this.forEach(function(itemInArray) { | |
results.push(projectionFunction(itemInArray)); | |
}); | |
return results; |