All Questions
Tagged with arrays javascript
93,176 questions
-1
votes
1
answer
32
views
How to display 3 elements by 3 of an array in HTML using array.sclice() method in javascript
I have found a way to display a portion of an array using arrayName.slice(start, end), i made a funtion to feed the start and end to the slice method so i can use it with onClick button to click next ...
0
votes
2
answers
66
views
How do optimise Array.sort or what is the best way to sort large size JSON
i am using default array.sort method inside my application here is my sample code
const jsonArray = Array.from({ length: 100000 }, (_, i) => ({
id: i,
principle: Math.random() * 1000,
...
1
vote
1
answer
37
views
Drag and Drop Swap in cards is not working
here is my code, and i am trying to Drag a .card (which includes an image),Drop it onto another .card and swap their content so they switch places visually. But it is not happening and also not ...
0
votes
0
answers
39
views
Returning an array from server-side to client-side in Svelte 5
I am using Svelte5. When I send an array from +page.server.js to +page.svelte it always works server-side and the array is sent as expected. However when +page.svelte is running on the client side ...
-2
votes
1
answer
110
views
How to sort a 2d array in Apps script (google sheet) base on a 1d array
I have a script that I have been using for some time, but I recently had a bug on the data sorter and since then I have been unable to fix the problem.
I transpose arrays because they are normally ...
-1
votes
3
answers
90
views
Shift data associated with an array's index based on filter data
I have an array of any values, as well as data associated with each value.
This data is stored as Record<string,FooData> where the key is generated using the index within the array.
However, I ...
1
vote
1
answer
49
views
Reactive form module is getting time to render in case of edit mode
i am using angular reactive from module to my application here is my html code
<form *ngIf="myForm" [formGroup]="myForm" (submit)="onSubmit()">
<mat-select ...
-2
votes
0
answers
41
views
How to build an object or array with unique key names from unique array object values with all array items with said unique key nName [duplicate]
I would like to produce an array (plus, separately, an object, if possible) from the unique 'custRef' values in the following array:
[
{
"id": 1233,
"custRef": "...
0
votes
1
answer
56
views
Backtracking confusion
Concerning Javascript, I've been trying to understand backtracking lately and it's really confusing. Specifically, I've been trying to understand the permutation problem, which when given an array, we ...
1
vote
1
answer
116
views
Matching Card Game using JS
*{
box-sizing: border-box;
}
.clear {
clear: both;
}
section {
border: 1px solid black;
height: 200px;
width: 50%;
float: left;
}
<!DOCTYPE html>
<html lang="en">
<...
-3
votes
0
answers
31
views
How to access a member of an object array in JavaScript [duplicate]
I am doing an exercise. I am having an issue accessing an object array's members. I have the following object array declaration:
const dishData = [
{
name: "Italian pasta",
price: 9.55
},
{
...
0
votes
1
answer
38
views
Correct way to generate a nested array from an ajax call for google maps
I'm trying to generate a map of tradespeople nearby to the site visitor. I've figured out most of it and am stuck on the final part mainly due to gaps in knowledge when it comes to arrays, structures ...
0
votes
0
answers
27
views
Storing an object key/value in an array but not in an array element [duplicate]
I found some odd things and am looking for explanations as to how and why
let a = [] ;
a.push({foo:"bar",bar:"foo"}] ;
console.log(a) ;
As expected, prints out:
[[object Object] {
...
1
vote
2
answers
132
views
Can i get multer to parse an array of strings in formdata as an array, and not as a comma seperated string?
I am using axios to send a FormData object, containing a categories field, an array of strings, to an express server. I am using multer to parse the FormData recieved, however req.body.categories is a ...
-4
votes
1
answer
75
views
Rewriting nested loop with reduce [closed]
I wrote the below code to solve a prep test, found online. The goal is to find the min absolute difference between numbers in an array.
function minimumAbsoluteDifference(arr: number[]): number {
/...