Skip to content

Instantly share code, notes, and snippets.

@JakeTheCorn
Created January 22, 2018 15:42
Show Gist options
  • Save JakeTheCorn/f16669da5095d1133548db828b64ac91 to your computer and use it in GitHub Desktop.
Save JakeTheCorn/f16669da5095d1133548db828b64ac91 to your computer and use it in GitHub Desktop.
nge.js
const NumRange = (function CreateRangeObject() {
return {
from: from
}
function from(num1) {
var arr = [];
return {
to: to
}
function to(num2) {
if (num1 < num2) {
while (num1 <= num2) {
arr.push(num1);
num1++;
}
} else if (num1 > num2) {
while (num1 >= num2) {
arr.push(num1);
num1--;
}
} else {
return num1;
}
return arr;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment