Skip to content

Instantly share code, notes, and snippets.

View 70853n's full-sized avatar
🤓
Learning a lot

Tobias Szczepanski 70853n

🤓
Learning a lot
View GitHub Profile
@70853n
70853n / .js
Created October 1, 2020 10:13
JavaScript range array and object with calculated keys
const upperRangeBoundry = 5;
const rangeSizedArray = [...Array(upperRangeBoundry)]
// -> (5) [undefined, undefined, undefined, undefined, undefined]
const rangeValuedArray = [...Array(upperRangeBoundry).keys()]
// -> (5) [0,1,2,3,4]
[...Array(8)].map((_, index, range) => 100 * index/range.length);
// -> (8) [0, 12.5, 25, 37.5, 50, 62.5, 75, 87.5]