Skip to content

Instantly share code, notes, and snippets.

@kaleem-elahi
Last active February 20, 2020 07:53
Show Gist options
  • Save kaleem-elahi/cb073087adee3acfe2db4878a8d3a0cd to your computer and use it in GitHub Desktop.
Save kaleem-elahi/cb073087adee3acfe2db4878a8d3a0cd to your computer and use it in GitHub Desktop.
generate number by Values and alphabets by counts
/**
*
* 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