Skip to content

Tag: arrays

js: fill object with array elements using reduce()

trying to learn reduce() but can’t understand it well yet. Maybe someone from you could help me with my problem. I have an object with defined keys and an array. I would like to fill up the objects keys with the arrays values using reduce(). My sandbox LINK Till now I tried something like this: expected…

I am trying to solve a challenge from jshero.net

I am trying to solve a challenge from jshero.net Write a function add that adds an element to the end of an array. However, the element should only be added if it is not already in the array. Example: add([1, 2], 3) should return [1, 2, 3] and add([1, 2], 2) should return [1, 2]. why didn’t work this co…