JSFiddle - React, Tailwind, and code Playground

by Alex Alex

Babel + JSX

const maxSteps = 5;
const getStepsValue = (min, max) => {
  const maxStepOrder = Math.abs(max).toFixed(0).length;
  const minStepOrder = Math.abs(min).toFixed(0).length;
  const maxSign = max ? Math.abs(max) / max: 1;
  const minSign = min ? Math.abs(min) / min : 1;

  if (maxSign === minSign) {
  	const step = 10 ** maxStepOrder / maxSteps;
	  return Array(maxSteps+1).fill(0).map((n, i) => n + step * i);
  }

	const step = 10 ** maxStepOrder + 10 ** minStepOrder / maxSteps;
  return Array(maxSteps+1).fill(-10**minStepOrder).map((n, i) => n + step * i);
}
const results = [];
results.push([0, 10, "steps", ...getStepsValue(0, 10)]);
results.push([10, 10, "steps", ...getStepsValue(10, 10)]);
results.push([10, 100, "steps", ...getStepsValue(10, 100)]);
results.push([10, 1000, "steps", ...getStepsValue(10, 1000)]);
results.push([10, 10, "steps", ...getStepsValue(10, 10)]);
results.push([-10, 10, "steps", ...getStepsValue(-10, 10)]);
results.push([-100, 10, "steps", ...getStepsValue(-100, 10)]);

console.table(results);