I have an array like this:
formTemporary: [50, '', 50, '', 50]
and I have an object like this
formEntry: {25}
and I want to add formEntry
to the array.
I want the formTemporary
like this:
formTemporary: [50, 25, 50, 25, 50]
After the array complete I want to sum the array with .reduce
. I want to know how to add the value of formEntry
to formTemporary
.
const formEntry = 25;
let formTemporary = [50, '', 50, '', 50];
formTemporary = formTemporary.map(record => record || formEntry);
console.log(formTemporary);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.