Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Created April 14, 2020 15:17
Show Gist options
  • Save jasonbellamy/5efe55cb7f8d8bdb4045326768ed7b1a to your computer and use it in GitHub Desktop.
Save jasonbellamy/5efe55cb7f8d8bdb4045326768ed7b1a to your computer and use it in GitHub Desktop.
JavaScript Assessment

Question One:

Create a function that when given the following input:

[
    {
        a: [ 1, 2, 3, 4, 5 ]
    },
    {
        a: [ 1, 2, 3, 4 ]
    },
    {
        a: []
    },
    {
        b: [ 5, 4, 3, 2, 1 ]
    },
    {
        b: [ 5, 4, 3, 2 ]
    },
    {
        b: [ 0 ]
    }
]

Produces the following output:

{
  a: 25,
  b: 29
}

Question Two:

Implement the following functions:

const addOneAndDouble = compose(addTwo, double, addOne)

So that when the following is called:

addOneAndDouble(12)

It produces the result of 28

Question Three:

Create 2 custom implementations of the filter method.

so that the following expression:

filter(x => x != 'a')(['a', 'b', 'c', 'd'])

produces the following result:

['b', 'c', 'd']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment