Amazon SDE 2 assessment - Need Solution Javascript - 2nd March, 2022

Array of Types Sorting
Your task it to write a function that takes an array containing values of different types and returns an object that lists all the different types grouped in respective sub-sections.

Examples
Types Input Output
Primitive types [ 1, "string", 2, true, false ] { number: [ 1, 2 ], string: [ "string" ], boolean: [ true, false ] }
Differrent Object Types [ {}, [], null ] { object: [ {} ], array: [ [] ], null: [ null ] }
Edge Cases
Class instances do not need to be considered and can be treated as type object for this assignement.

const filterArray = () => {
  // fill me with code
}

export default filterArray

Test

import filterArray from './solution'

describe('basic tests', () => {
  test('strings', () => {
    expect(filterArray(["a", "b", "c"])).toEqual({ string: ["a", "b", "c"] })
  })
})```
Comments (2)