Interview Prep

Javascript Closures

Closures are also known as lexical scoping.  It is a result of functions that can nest, and functions that are values.  The context of the inner function includes the scope of the outer function.  The image below is taken from Crockford’s “The Good Parts of JavaScript and the Web” course on Front-End Masters (I watched […]

_.map – Javascript Problem

This is an exercise taken from the Javascript: From Fundamentals to Functional course by Bianca Gandolfo on FrontEnd Masters.  The characters are taken from a game of Clue – a murder whodunit… Here I have recreated a map() method in a slightly different way.  Instead of attaching it to the array prototype, I created it […]

_.forEach – Javascript Problem

This is an exercise taken from the Javascript: From Fundamentals to Functional course by Bianca Gandolfo on FrontEnd Masters.  The characters are taken from a game of Clue – a murder whodunit… Here I have recreated a forEach() method in a slightly different way.  Instead of attaching it to the array prototype, I created it […]

Javascript – Curry Functions

Wikipedia has the following to say about currying: In mathematics and computer science, currying is the technique of translating the evaluation of a function that takes multiple arguments (or a tuple of arguments) into evaluating a sequence of functions, each with a single argument. Currying is related to, but not the same as, partial application. […]

Javascript Problems – Create my own Array.prototype.map() method – myMap()

In this exercise, I will create my own map method – myMap(). According to MDN Developers Network, “The map() method creates a new array with the results of calling a provided function on every element in the calling array.” I have used the same sample data and functions as I did for the myForEach problem.  […]

Javascript Problems – Create my own Array.prototype.filter() method – myFilter()

The purpose of this exercise is to create my own Array.prototype.filter() method – myFilter().  On line 2, I add a new myFilter() method, which takes in a function as an argument, to the array object.  I loop through each item in the array that called the method, and on line 6 determine if the function has […]

Javascript Problems – Create my own Array.prototype.forEach() method – myForEach()

The purpose of this exercise is to create my own Array.prototype.forEach() method – myForEach(). According to the MDN Developers page for Array.prototype.forEach(), “The forEach() method executes a provided function once for each array element”. I use the same sample data sets as I did or the myMap() method.  Whereas myMap() modifies each element in the […]

Javascript Problems – Create my own Array.prototype.reduce() method – myReduce()

In this exercise, I create my own Array.prototype.reduce() method – myReduce().  On line 3, I add a new method to the Array object which takes in a function and an initial value.  Starting on line 5, I loop through the array that calls this method.  The function called is applied to each element, and the […]

Javascript Problems — Select only object from array

The goal of this exercise is to take an array of items: objects, arrays, numbers, strings and null, and return only true objects.  Both null and arrays are objects in Javascript, so I have to test for those specifically.  First I used the reduce method.  On line 7, I test if an item is null […]

Javascript Problems – Sum two numbers

In this problem, I create a function that either takes in two arguments to be added OR is invoked twice to add the numbers.  On line 6, I test to see if there is no argument b.  If there is no argument b, I run an anonymous function that takes in the argument from the second […]