I want make a table with headers from 8 to 23 and use es6 and arrays methods I have this code to make array:
const column = Array.from(Array(16), (_, x) => [x 8]).fill({
title: 8,
});
My current output :
Expected output :
What should I do?
CodePudding user response:
Use the index provided by the callback to increment from 8 forward
const column = Array.from({ length: 16 }, (_, i) => ({ title: 8 i }));
console.log(column)
CodePudding user response:
const column = Array.from(Array(16), (_, x) => [x 8]).map(e => {
return { title: e[0] }
});