All Questions
Tagged with arrays javascript
93,127
questions
-8
votes
0
answers
28
views
How to get and sort a string from an array in javascript? [closed]
I have this array with this string:
['MEX-CUN'] ['MEX-MTY']
and I would like a result similar to this:
CUNMEX
MEXMTY
Is it possible to perform this action?
0
votes
1
answer
32
views
Find the average per index in a matrix
I'm looking to get the average of each index in a matrix row in JS
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
Then returning a list with the average of each row index : [4, 5, 6]
Would I create a loop, save each ...
1
vote
0
answers
36
views
Multiple adding to cart in JavaScript doesn't work
when I add products to the shopping cart at some point it stops updating the table, it is refreshed when I click the previous product and the product I want to add.
Live site: https://frontend-mentor-...
-1
votes
3
answers
72
views
Todo list using array and loop
I want to create a todo list using array and loop and display the list in div container. I am able to display the list but it is muliplying the same list stored and is displayed.
<body>
<...
-1
votes
0
answers
17
views
How can I convert a multidimensional array from x by y to y by x? [duplicate]
Given the 3x2 multidimensional array:
const arr = [
[1, 3, 5],
[2, 4, 6]
]
where (1,2) === 2 and where (3,1) === 5 and etc
How can I convert it to the 2x3 multidimensional array:
const arr = [
[...
-1
votes
3
answers
42
views
Retrieve array data that every nested array contains
The main goal is to select all the colors that every car.colors contain, if there's no color that every car have then the expected output is an empty array.
Having an array that contains text, and a ...
0
votes
0
answers
13
views
Google Earth Engine: error "Invalid type. Expected type: Number" trying to compute a Number while performing histogram matching on satellite images
I am working on satellite imagery on Google Earth Engine (JavaScript), and I'm experiencing some issues while I try to perform histogram matching on two images from two different time periods.
In ...
0
votes
0
answers
38
views
Leetcode output is different from visual studio code output
I just started on my leetcode exercises and I ran into a bit of a problem. I usually work on the leetcode problems on vsc and then when I got my answer, i just copaste it onto the leetcode answer box.
...
-1
votes
1
answer
42
views
Javascript: How to compare a parent array of array with more than two similar elements of another array and return unique array of arrays
const array1 = [[1, 2, 3], [1,3,4], [1,2,5]];
let b = []
let c = [2,3]
array1.forEach(e => {
c.some(r => {
if(e.includes(r))
b.push(e)
})
})
console.log(b)
got the ...
0
votes
1
answer
21
views
useState returning empty array on default state, using react + supabase
I need help to understand why when I console.log(menus) on Menu.jsx it returns an array of values, but if I console.log(item) it only returns an empty array, while the default value of the item is &...
1
vote
1
answer
38
views
How to stop the second console.log from including the array of the first in its calculations?
I made a function that will find the sum of whatever array you put in. The problem is that if I have 2 of these console.log up, the second will add the sum of the first to it's result. What am I doing ...
0
votes
0
answers
26
views
How do get search filter data in es6
// Filter rows based on string values and exclude from whiteList
const whiteList = rows.map(sel => sel.RuleAutoID); // Array of IDs to exclude
console.log('whiteList', whiteList);
// Assuming you'...
-1
votes
2
answers
33
views
Extracting values from array and adding them to new elements
I've got some code which loops through an array of products, it records new categories found and also how many times a category is found:
const categoriesFound = (catArray) => {
let categories = {...
3
votes
2
answers
61
views
Traverse over tree type structured data uing JavaScript
I have a data set having parent and nested children in it. The purpose of this data is to traverse over parent to -> child1 to-> Child1Child .....
-> child2 to -> child1 to -> child2 ...
2
votes
1
answer
53
views
javascript setting a .map() range and update the range later
I'm building an app with React & JS which returns products from a json list inside a component, the array is outputted on the app using a .map() array. I'm also limiting the amount to return ...