Write a JavaScript program to initialize an array containing the numbers in the specified range where start and end are inclusive with their common difference step
- برمجة جافاسكربت java script
- برمجة
- 2021-06-03
- ahmadghneem
الأجوبة
const initialize_Array_With_Range = (end, start = 0, step = 1) =>
Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start);
console.log(initialize_Array_With_Range(5));
console.log(initialize_Array_With_Range(8, 3));
console.log(initialize_Array_With_Range(6, 0, 2));
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال