Skip to content

Tag: arrays

Why function returns filtered boolean array

I learn js and trying to write filter method without using it. So I need to my function return filtered array based on function, which passed as a parameter. And it does but it’s returned boolean array and I don’t understand why. My code: Calling with some numbers: myFilter([2, 5, 1, 3, 8, 6], fun…

Filter array of infinitely nested objects

Let’s say I have an array of nested objects such as: And I would like to return a new array with id: 3 excluded for example. So it would become: The excluded id can be from any level, and it and its children should be removed. What’s the best approach to do this? I’ve tried several other sol…

vue js ARRAY push

I have an array(rows) inside an array(tabs). I want to duplicate the the array. now how do I duplicate the rows array and tabs array separately. Like when I click “Add row” button a row will be added and when I click the “add tab” button the whole tab with row will be added. I am tryin…

Reset an array and have it be mutable again

I am making tic-tac-toe from TOP, I’m not looking for someone to do my homework I just think I’m severely misunderstanding arrays, and or scope. I have a module “Game” where I store the game info It is all controlled from a controller module, that sets up the players, plays the round, …

JavaScript Array Filtering in Nested Arrays

I have an array that looks something like this: What I want is to filter the objects whose itemsList contain an object with the name of a certain value. For example, I want to be able to filter out an array with objects whose inner objects with names that contain “ul” (in this case the name Paul c…