Manipulate an array of objects inside another array

I’m having a problem manipulating an array of objects inside another array.I created an example to explain what I need. So here we have this array: array1 = [ { "first": "A", "second": [ "one" ] }, { "first": "A", "second": [ "three" ] }, { "first": "C", "second": [ "four" ] }, { "first":… Read More Manipulate an array of objects inside another array

How to read from a .txt file into an array of objects

I have the following sample data in a .txt file 111, Sybil, 21 112, Edith, 22 113, Mathew, 30 114, Mary, 25 the required output is [{"number":"111","name":"Sybil","age":"21" }, {"number":"112","name":"Edith","age":"22"}, {"number":"113","name":"Mathew","age":"30"}, "number":"114","name":"Mary","age":"25"] Sadly, I have not gone far because I cant seem to get the values out of each line. instead, this is what is displayed… Read More How to read from a .txt file into an array of objects

Find all unique values in array and than split it and return something else

My goal is to find all the unique years in this array and than return it as a array. I have almost done it but cant figure out how I will return the split value. function findUniqueYears() { const arr = [‘1973-11-01’, ‘2001-01-01’, ‘1999-10-01’, ‘2007-10-01’, ‘2016-06-01’, ‘2005-08-01’, ‘1973-09-01’, ‘1979-12-01’, ‘2001-08-01’]; for (var i = 0;… Read More Find all unique values in array and than split it and return something else

Combine objects in array in Javascript

I have an array of objects like follows 0: {bill_no: ‘0000633’, test_code: ‘1’, analyzer_code: ‘2’} 1: {bill_no: ‘0000633’, test_code: ‘2’, analyzer_code: ‘2’} 2: {bill_no: ‘0000633’, test_code: ’28’, analyzer_code: ‘3’} 3: {bill_no: ‘0000633’, test_code: ‘254’, analyzer_code: ‘2’} I want to combine those objects to get the following result (join the objects based on same analyzer_code). 0:… Read More Combine objects in array in Javascript

remove non-selected keys from array of objects or create new array of objects with only selected value

so I have this array to help me with my input select options Input select: <select id="example-select"></select> And the array with the options const array_axis = [‘2015’, ‘2016’, ‘2017’, ‘2018’, ‘2019’, ‘2020’];//these are the options of my input select This is how I use that array as options for my input select: var select =… Read More remove non-selected keys from array of objects or create new array of objects with only selected value