Preview:
function validNumber(...anyAmountOfArgs) {
    return anyAmountOfArgs.every((val) => Number.isFinite(val) && val > 0);
}

// Validate distance and duration always
// using 2 params
if (!validNumber(distance, duration)) {
  alert("Please enter positive numbers for distance and duration.");
  return;
}

// Validate cadence if running
// using 1 param
if (type === "running" && !validNumber(cadence)) {
  alert("Please enter a positive number for cadence.");
  return;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter