A GENTLE INTRODUCTION TO FUNCTIONAL JAVASCRIPT: PART 3
function curry (fn) {
var arity = fn.length;
function given (argsSoFar) {
return function helper () {
var args = Array.prototype.slice.call(arguments, 0);
var updatedArgsSoFar = argsSoFar.concat(args);[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], and the second argument is { last: "Capulet" }, then you must return the third object from the array (the first argument), because it contains the name and its value, that was passed on as the second argument.
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
sumAll([4,1]) should return 10 because sum of all the numbers between 1 and 4 (both inclusive) is 10.
The variable watchList holds an array of objects with information on several movies.
Use reduce to find the average IMDB rating of the movies directed by Christopher Nolan.
Recall from prior challenges how to filter data and map over it to pull what you need.
You may need to create other variables, and return the average rating from getRating function.
Note that the rating values are saved as strings in the object and need to be converted
into numbers before they are used in any mathematical operations.
My soln:
// the global variable