I have a function in javascript where the schoolClass
it's an roman number like this I
, II
, IV
etc. this function is called multiple times and the result it's concatenated in an array like this:
const generateClasses = (schoolClass, number) => {
const classes = [];
for (let i = 0; i < number; i++) {
classes.push(`${schoolClass}-${(i + 10).toString(36).toUpperCase()}`);
}
return classes;
};
let output = [];
output = output.concat(generateClasses('II', 2));
output = output.concat(generateClasses('I', 1));
output = output.concat(generateClasses('IV', 2));
console.log(output);
in the end the output it's like this:
["II-A", "II-B", "I-A", "IV-A", "IV-B"]
how to order the array-like ["I-A", "II-A", "II-B", "IV-A", "IV-V"]
I appreciate any help!
PS: for converting numbers in roman I use the roman-numbers
module