Sum multiple items in 2D array based on condition (javascript)
I have a 2D array: [ [ 1, 2, 43, 5 ], [ 1, 5, 12, 1 ], [ 2, 3, 6, 77 ], [ 2, 1, 48, 94 ], [ 3, 3, 15, 85 ], [ 3, 7, 97,…
I have a 2D array: [ [ 1, 2, 43, 5 ], [ 1, 5, 12, 1 ], [ 2, 3, 6, 77 ], [ 2, 1, 48, 94 ], [ 3, 3, 15, 85 ], [ 3, 7, 97,…
I want to check an array of dates to see if they are increasing. For example, ['12/12/2023','13/12/2023'] would return true. However, ['12/12/2023','11/12/2023'] would return false. I have been playing around with a function suggested by users for checking integer values.…
I created a multidimensional array to access each of the arrays I stored from a MySQL query, using this statement: $new_array[$n][$row['MLocID']] = $row; Below is the output from print_r(get_defined_vars(), true): [new_array] => Array ( [0] => Array ( [226] =>…
Let's say I have this array: const services = [ { id: 100, priority: 'Y', count: 300, payout: '30', id_region: 137 }, { id: 101, priority: 'N', count: 200, payout: '40', id_region: 153 }, { id: 102, priority: 'Y', count:…
I need to group the data from my 2d array into an associative array of associative arrays where d values are the first level keys, and the s values will become the second level keys, and the i values should…
Using this piece of code: function displayPixelValue(event) { const filteredLayers = map.getAllLayers().filter(function (layer) { return layer.get('name'); }); for (let i=0; i<filteredLayers.length; i++) { let reliefPattern = "_mbpd_"; if (filteredLayers[i].get('name').match(reliefPattern)) { const reliefValue = filteredLayers[i].getData(event.pixel); console.log(reliefValue); } } } map.on(['pointermove'], displayPixelValue);…
I have a collection of data like this: { "items": [ { "product": { "name": "prod1", "price": { "pledge": 1, "cost": 19 } } }, { "product": { "name": "prod2", "price": { "pledge": 2, "cost": 10 } } } ]…
I have to sort this array, const array = [ [18, [18, 16], 16], 15, [18, 19, 51], [[18, 16], 15, [14, 13]], [10, 9, 20], 99, 49, [11, [22, 10], [[10, 9], 11, 9, [1, 2]], 100, 72], [[11],…
I'm working on a program that aims to use an array of colors (that are stored as strings). I need to take the strings and change the color of a piece of text to a random color. Sample Array: let…
I am currently writing a Bash script to search through a JSONL file of Mario Maker level data (found in this Reddit post https://www.reddit.com/r/MarioMaker/comments/wlkwp9/easily_searchable_database_of_super_mario_maker_1/) and print the level id, name of the course, and name of the creator. I am…