Created
January 22, 2018 15:42
-
-
Save JakeTheCorn/f16669da5095d1133548db828b64ac91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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