Arrays
Data Types
const func = (N, p) => Array(N).fill().map((_,i)=>Math.abs(i-p));
function func(N, point) {let start = 0; // starting position of arraylet clonePoint = point; // clone for point to start counting from that number at begining of arraylet arr = [...Array(N).keys()] // generate array and fill with 0 to 10if(!(point > N)) {arr.forEach((o, index) => {index < point ? arr[index] = clonePoint-- : arr[index] = start++;});return arr;}return [];}- const func = (N, p) => Array(N).fill().map((_,i)=>Math.abs(i-p));