Last active
February 20, 2020 07:53
-
-
Save kaleem-elahi/cb073087adee3acfe2db4878a8d3a0cd to your computer and use it in GitHub Desktop.
generate number by Values and alphabets by counts
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
/** | |
* | |
* Author : Kaleem Elahi Shaikh | |
* Email: [email protected] | |
* | |
* / | |
/** | |
* create alpha order | |
* @param {*} n | |
* @param {*} order | |
*/ | |
export const genAlphabetsByNo = (n, order) => { | |
var a = []; | |
for (var i = 0; i <= (n - 1); ++i) { | |
a.push(String.fromCharCode(65 + i)); | |
} | |
if (order === 'desc') { | |
return a.reverse(); | |
} | |
return a; | |
} | |
/** | |
* create number order | |
* @param {*} n | |
* @param {*} order | |
*/ | |
export const genNumByValue = (n, order) => { | |
var a = []; | |
for (var i = 0; i <= (n - 1); ++i) { | |
a.push(i + 1) | |
} | |
if (order === 'desc') { | |
return a.reverse(); | |
} | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment