JSFiddle - React, Tailwind, and code Playground
by Scott Kaye
JavaScript
console.clear();
//Returns an array of values interpolated between the first and second element. Adds "null" to the end of the array if that array isn't supported/nothing to interpolate.
//Usage: [1, 3].interpolate(15) returns [1, 3, 5, 7, 9, 11, 13, 15]
Object.defineProperty(Array.prototype, "interpolate", {
value: function (m) {
var r = [this[0]],
s = this[1] - this[0],
i;
if (s && m > 0) {
for (i = 0; r[i] + s <= m; r.push(r[i++] + s));
return r;
}
return this.concat(null);
}
});
var test = [1, 3].interpolate(15);
console.log(test);