Why is my JSON array prototype mapping not working?

I’m trying to map the array in my JSON file but I’m doing something wrong and I can’t figure out what. When I do console.log the result is "undefined". I have the feeling that the error might be in my JSON file and not necessarily in the .map function but I can’t figure it out.… Read More Why is my JSON array prototype mapping not working?

How to map through an array of objects and add the total in each object to a variable in Javascript

Here is an array of objects const items = [{description: "Cement", total: "150"}, {description: "Mortar", total: "200"}, {description: "Sand", total: "100"}] I want to add the total of each object to a variable so that i can get the grand total of everything. I have tried mapping through the items array and then for each… Read More How to map through an array of objects and add the total in each object to a variable in Javascript

JavaScript – Map over two object arrays, match key, and store key and property as array

I have two arrays: Array 1: [‘0000037_165’, ‘0000037_62’, ‘0000037_74’, ‘0000037_165’, …] Array 2: [ {SiteUniqueID: ‘0000037_165’, Description: ‘Description 1’}, {SiteUniqueID: ‘0000037_165’, Description: ‘Description 2’}, {SiteUniqueID: ‘0000037_62’, Description: ‘Description 1’}, {SiteUniqueID: ‘0000037_74’, Description: ‘Description 1’}, {SiteUniqueID: ‘0000037_165’, Description: ‘Description 1′}, … ] I need to map over both arrays and check if the ‘SiteUniqueID’ from array… Read More JavaScript – Map over two object arrays, match key, and store key and property as array

How do I use map() on an object array that has a periods in its object keys? Index notation doesn't work

I thought for sure this would have been asked before, I tried searching but feel free to point me in the right direction. So here’s the problem data, lets call it "data": [ { "Wetlands.WETLAND_TYPE": "Freshwater Forested/Shrub Wetland" }, { "Wetlands.WETLAND_TYPE": "Lake" }, { "Wetlands.WETLAND_TYPE": "Riverine" } ] JS: const myWetlands = data.map(({ Wetlands.WETLAND_TYPE })… Read More How do I use map() on an object array that has a periods in its object keys? Index notation doesn't work

Using .map() to iterate over an array of Object values and reassign to new keys

I am trying to transform the data below from: { title: ‘The Promise’, blurb: ‘Lorem Ipsum’, cover_image: ‘Lorem Ipsum’, pub_year: 2002, genre: ‘Foobar’ } To: [ { col1: ‘The Promise’, col2: ‘Lorem Ipsum’, col3: ‘Lorem Ipsum’, col4: 2002 col5: ‘Foobar’ }, ] I have been puzzling away at this for quite a while and can… Read More Using .map() to iterate over an array of Object values and reassign to new keys