Ad
Arrays
Data Types

Function will recive N for length of array and point as index to pint at in that array.


For example, function should generate arrays like this for


N = 10, point = 7
[7,6,5,4,3,2,1,0,1,2]


N = 10, point = 4
[4,3,2,1,0,1,2,3,4,5]

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