Based on Charles Clayton's response, I included some JSDoc, ES6 tweaks, and incorporated suggestions from the comments in the original response.
/**_x000D_
* Returns a scaled number within its source bounds to the desired target bounds._x000D_
* @param {number} n - Unscaled number_x000D_
* @param {number} tMin - Minimum (target) bound to scale to_x000D_
* @param {number} tMax - Maximum (target) bound to scale to_x000D_
* @param {number} sMin - Minimum (source) bound to scale from_x000D_
* @param {number} sMax - Maximum (source) bound to scale from_x000D_
* @returns {number} The scaled number within the target bounds._x000D_
*/_x000D_
const scaleBetween = (n, tMin, tMax, sMin, sMax) => {_x000D_
return (tMax - tMin) * (n - sMin) / (sMax - sMin) + tMin;_x000D_
}_x000D_
_x000D_
if (Array.prototype.scaleBetween === undefined) {_x000D_
/**_x000D_
* Returns a scaled array of numbers fit to the desired target bounds._x000D_
* @param {number} tMin - Minimum (target) bound to scale to_x000D_
* @param {number} tMax - Maximum (target) bound to scale to_x000D_
* @returns {number} The scaled array._x000D_
*/_x000D_
Array.prototype.scaleBetween = function(tMin, tMax) {_x000D_
if (arguments.length === 1 || tMax === undefined) {_x000D_
tMax = tMin; tMin = 0;_x000D_
}_x000D_
let sMax = Math.max(...this), sMin = Math.min(...this);_x000D_
if (sMax - sMin == 0) return this.map(num => (tMin + tMax) / 2);_x000D_
return this.map(num => (tMax - tMin) * (num - sMin) / (sMax - sMin) + tMin);_x000D_
}_x000D_
}_x000D_
_x000D_
// ================================================================_x000D_
// Usage_x000D_
// ================================================================_x000D_
_x000D_
let nums = [10, 13, 25, 28, 43, 50], tMin = 0, tMax = 100,_x000D_
sMin = Math.min(...nums), sMax = Math.max(...nums);_x000D_
_x000D_
// Result: [ 0.0, 7.50, 37.50, 45.00, 82.50, 100.00 ]_x000D_
console.log(nums.map(n => scaleBetween(n, tMin, tMax, sMin, sMax).toFixed(2)).join(', '));_x000D_
_x000D_
// Result: [ 0, 30.769, 69.231, 76.923, 100 ]_x000D_
console.log([-4, 0, 5, 6, 9].scaleBetween(0, 100).join(', '));_x000D_
_x000D_
// Result: [ 50, 50, 50 ]_x000D_
console.log([1, 1, 1].scaleBetween(0, 100).join(', '));
_x000D_
.as-console-wrapper { top: 0; max-height: 100% !important; }
_x000D_