How do I get all columns as an array from a 2d array which is a rectangle

Q: What do I mean by saying rectangle? A: [[1,2,3],[1,2,3]] Inner arrays have more elements. Example: Input: [[1,2,3,4],[1,2,3,4],[1,2,3,4]] Desired Output: [[1,1,1],[2,2,2],[3,3,3],[4,4,4]] Output: [[1,1,1],[2,2,2],[3,3,3]] The reason of the problem: Main array has less elements, so, when I loop over it, as expected it will return an array with its own length. Shown in the example above.… Read More How do I get all columns as an array from a 2d array which is a rectangle

How to add special character in array map?

How to add special characters like : to array map ? I want to achieve this. ’10’: [“11/21/2022”, “11/25/2022”] this is what I have so far const data = [{ “user_id”: “10”, “dates”: [“11/21/2022”, “11/25/2022”] }] const output = data.map(({ user_id, dates }) => [user_id, dates]); console.log(output); >Solution : I’m going to guess that you’re… Read More How to add special character in array map?

combine array of object if atleast one property is common

//this one is actual array const data = [ { name: ‘shanu’, label: ‘ak’, value: 1, }, { name: ‘shanu’, label: ‘pk’, value: 2, }, { name: ‘bhanu’, label: ‘tk’, value: 3, }, ]; > //and this is the array that I want let outPut = [ { name:’shanu’, label:[‘ak’,’pk’], value:[1,2] }, { name:’bhanu’, label:[‘tk’],… Read More combine array of object if atleast one property is common