Skip to content

Instantly share code, notes, and snippets.

@guz-anton
Created March 25, 2021 21:28
Show Gist options
  • Save guz-anton/4035c91e9f9cd73ba8d4add2b9abc65a to your computer and use it in GitHub Desktop.
Save guz-anton/4035c91e9f9cd73ba8d4add2b9abc65a to your computer and use it in GitHub Desktop.
const toDigit = (...values) => {
const isValue = x => x != null && !isNaN(x) && isFinite(x);
return +values.find(isValue) || 0;
}
const toDigit = (...values) => +values.find(x => x != null && !isNaN(x) && isFinite(x)) || 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment