Push value to multiple arrays

const array = [{ id: 1, name: ‘test’, attrs: [{ name: ‘Attribute 1’, description: ‘Description 1’, }], values: [{ name: ‘value 1’, attrs: [{ name: ‘Attribute 1’, type: ‘Type 1’, }, { name: ‘Attribute 2’, type: ‘Type 2’, }, ], }, ], }, ]; const newArray = array.map((item) => { return { …item, isNegative: true… Read More Push value to multiple arrays

How to extend a list of object array using for loop

// First i=0 let posi_val=[{top: ‘3px’, left: ‘2px’}]; // Second i=1 let posi_val=[{top: ‘3px’, left: ‘2px’},{top: ‘6px’, left: ‘4px’}]; // Third i=2 let posi_val=[{top: ‘3px’, left: ‘2px’},{top: ‘6px’, left: ‘4px’},{top: ’12px’, left: ‘8px’}]; Dear all, the above code is part of code to create css class (multiple red dots) on different postion, may I ask… Read More How to extend a list of object array using for loop

Dynamic Sorting Loop

I am trying to write a function which would loop through a list of positions in an array(Position Array) and for each position create an array in the Position Array. And then loop through another array with candidates with different positions and sort them into the arrays with the same positions within the Position Array.… Read More Dynamic Sorting Loop

Function returns undefined when using event.target.value in find(), but works when setting useState variable

I’m struggling with a strange issue. I have a select component that passes a value called "classID" up to a useState. I have an array mapped over the select component that looks like this (sent from NodeJS API): [{classID: 371, teacherID: 1, subjectID: 3, subjectTitle: ‘Mathematics’, subjectLevel: ‘IGCSE Level’, …}, {classID: 370, teacherID: 1, subjectID:… Read More Function returns undefined when using event.target.value in find(), but works when setting useState variable