All Questions
13
questions
3
votes
2
answers
2k
views
Add a new key and value to a Javascript object from an existing array of values
I have an existing array of ids that I'm trying to iterate over to add each as an id: key to an existing array of objects. I have tried a number of different loops (for, for in, map, forEach), but I ...
0
votes
2
answers
895
views
How to turn 2 arrays into an object with key value pairs
I have an object which contains 2 objects with properties:
const objects = {
Battery: {
batteryDetailsKey: ['serial_no', 'type', 'part_no'],
batteryDetailsVal: [
'HJ3CA19347410218LJ98 ...
-1
votes
5
answers
651
views
How can I loop over a multi level JSON object and create a new Javascript object from one of it's key and values
I have a JSON object that looks like the following
{
"venue": {
"time1": [
{
"Status": "Available"
},
...
0
votes
3
answers
153
views
Efficient way to get top count of an option in an array of objects
I have an array of objects like this,
[
{
user: 'A',
answers: [
{
id: 1,
score: 3,
},
{
id: 2,
score: 1,
},
...
]
},
{
...
1
vote
5
answers
83
views
push value duplicate into new array
I have array of object like this
const data = [
{
name: "John",
transaction: "10/10/2010",
item: "Bag"
},
{
name: "Steven",
...
1
vote
1
answer
186
views
Javascript ES6 better way to loop object and match with multiple nested object and return id
I have it done but I think is not the best. I want to find out a better way (ES6) to loop multiple nested objects and met a condition and return id like below outcome (with and without)
I have two ...
1
vote
2
answers
23
views
replacing key object for the array values
Im having a problem with replacing keys in object
let headers = ['title1', 'title2', 'title3']
let obj = {
0: ['name1', 'name2, 'name3],
1: ['example1', 'example2, 'example3],
2: ['xx', '...
-2
votes
1
answer
393
views
Function looping through object keys throws undefined
I'm trying to iterate through an Inventory object when the sale fucntion is called, and it should check the article requested and its amount.
Always updating the inventory when a sale is made, and if ...
-1
votes
2
answers
315
views
How do I push a field of an object into another array of object
I know how to operate on array of objects but never had the necessity to populate an array data into another. I need to populate firstname + lastname field into name field of birth array
let birth = [...
1
vote
3
answers
809
views
Why this object destructuring in for-of loop doesn't work?
Basically the following code doesn't work and I don't understand why.
in the nested loop, I have a variable called "children" that is an array containing objects with fields called children (like in a ...
2
votes
3
answers
121
views
How to create a new array of objects form object without duplicates ? (ES6)
I would like to create an array of all "department" from the "users" array without duplicate in ES6.
I've tried with forEach, reduce, filter, without success...
Users array:
let users = [{
...
0
votes
4
answers
62
views
Convert values in array of objects [duplicate]
I have an array of objects with String values that I want to convert to Date, but I'm getting the following error:
Uncaught SyntaxError: Unexpected token :
How should I correctly do this ...
1
vote
2
answers
112
views
ES6 implementation of this function?
This function loops through an array of objects, and takes an object as a second parameter.
It will loop through the array of objects replacing it with the object passed in as the second argument if ...