javascript - Nested map and filter methods -


i trying wrap head around functional programming in javascript. goal retrieve object boxarts items width=150 , height=200.

console.log(arr) 

displays

[ [ [ [object] ], [ [object] ] ], [ [ [object] ], [ [object] ] ] ] 

i not sure why unable print actual values. concatall method used flatten arrays. working through reactivex.io tutorial on functional programming.

array.prototype.concatall = function() {  var results = [];  this.foreach(function(subarray) {  	subarray.foreach(function(item){    	results.push(item);  });  });    return results;  };    var movielists = [  		{  			name: "instant queue",  			videos : [  				{  					"id": 70111470,  					"title": "die hard",  					"boxarts": [  						{ width: 150, height: 200, url: "http://cdn-0.nflximg.com/images/2891/diehard150.jpg" },  						{ width: 200, height: 200, url: "http://cdn-0.nflximg.com/images/2891/diehard200.jpg" }  					],  					"url": "http://api.netflix.com/catalog/titles/movies/70111470",  					"rating": 4.0,  					"bookmark": []  				},  				{  					"id": 654356453,  					"title": "bad boys",  					"boxarts": [  						{ width: 200, height: 200, url: "http://cdn-0.nflximg.com/images/2891/badboys200.jpg" },  						{ width: 150, height: 200, url: "http://cdn-0.nflximg.com/images/2891/badboys150.jpg" }    					],  					"url": "http://api.netflix.com/catalog/titles/movies/70111470",  					"rating": 5.0,  					"bookmark": [{ id: 432534, time: 65876586 }]  				}  			]  		},  		{  			name: "new releases",  			videos: [  				{  					"id": 65432445,  					"title": "the chamber",  					"boxarts": [  						{ width: 150, height: 200, url: "http://cdn-0.nflximg.com/images/2891/thechamber150.jpg" },  						{ width: 200, height: 200, url: "http://cdn-0.nflximg.com/images/2891/thechamber200.jpg" }  					],  					"url": "http://api.netflix.com/catalog/titles/movies/70111470",  					"rating": 4.0,  					"bookmark": []  				},  				{  					"id": 675465,  					"title": "fracture",  					"boxarts": [  						{ width: 200, height: 200, url: "http://cdn-0.nflximg.com/images/2891/fracture200.jpg" },  						{ width: 150, height: 200, url: "http://cdn-0.nflximg.com/images/2891/fracture150.jpg" },  						{ width: 300, height: 200, url: "http://cdn-0.nflximg.com/images/2891/fracture300.jpg" }  					],  					"url": "http://api.netflix.com/catalog/titles/movies/70111470",  					"rating": 5.0,  					"bookmark": [{ id: 432534, time: 65876586 }]  				}  			]  		}  	];    var arr = movielists.map(function(movielist) {  	return movielist.videos.map(function(video) {  		return video.boxarts.filter(function(boxart) {  			return boxart.width === 150;  		  });  	  });   });    console.log(arr);

ok, figured out. console.log(json.stringify(arr)); displaying values in repl.it, environment using.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -