youYou don't need the count variable to increment the index, Array.forEach accepts a second ( optional ) parameter which is the current index that you can use :
stored.forEach((obj, ndxindex) => { obj.value = input[ndx];input[index]; });
OR
stored = stored.map((eobj, ndxindex) => ({...eobj, value: input[ndx]input[index]}))
example :
let stored = [{ name : 'a', value: 2 }, {name : 'b', value: 4 }, { name : 'c', value: 6 }];
let input = [10, 11, 12];
stored.forEach((obj, ndxindex) => { obj.value = input[ndx];input[index]; });
// OR
// stored = stored.map((eobj, ndxindex) => ({...eobj, value: input[ndx]input[index]}))
console.log(stored)
you don't need the count variable to increment the index, Array.forEach accepts a second ( optional ) parameter which is the current index that you can use :
stored.forEach((obj, ndx) => { obj.value = input[ndx]; });
OR
stored = stored.map((e, ndx) => ({...e, value: input[ndx]}))
example :
let stored = [{ name : 'a', value: 2 }, {name : 'b', value: 4 }, { name : 'c', value: 6 }];
let input = [10, 11, 12];
stored.forEach((obj, ndx) => { obj.value = input[ndx]; });
// OR
// stored = stored.map((e, ndx) => ({...e, value: input[ndx]}))
console.log(stored)
You don't need the count variable to increment the index, Array.forEach accepts a second ( optional ) parameter which is the current index that you can use :
stored.forEach((obj, index) => { obj.value = input[index]; });
OR
stored = stored.map((obj, index) => ({...obj, value: input[index]}))
example :
let stored = [{ name : 'a', value: 2 }, {name : 'b', value: 4 }, { name : 'c', value: 6 }];
let input = [10, 11, 12];
stored.forEach((obj, index) => { obj.value = input[index]; });
// OR
// stored = stored.map((obj, index) => ({...obj, value: input[index]}))
console.log(stored)
you don't need the count variable to increment the index, Array.forEach accepts a second ( optional ) parameter which is the current index that you can use :
stored.forEach((obj, ndx) => { obj.value = input[ndx]; });
OR
stored = stored.map((e, ndx) => ({...e, value: input[ndx]}))
example :
let stored = [{ name : 'a', value: 2 }, {name : 'b', value: 4 }, { name : 'c', value: 6 }];
let input = [10, 11, 12];
stored.forEach((obj, ndx) => { obj.value = input[ndx]; });
// OR
// stored = stored.map((e, ndx) => ({...e, value: input[ndx]}))
console.log(stored)