Skip to content

Instantly share code, notes, and snippets.

@adarshaacharya
Created June 28, 2021 18:04
Show Gist options
  • Save adarshaacharya/f2c23564880db03e36a8e64ed3523e7c to your computer and use it in GitHub Desktop.
Save adarshaacharya/f2c23564880db03e36a8e64ed3523e7c to your computer and use it in GitHub Desktop.
convert enums into list of arrays
/**
* convert enums into list of arrays
*/
enum UserRole {
Student = 'STUDENT',
Teacher = 'TEACHER',
}
const list = (enm: Record<string, unknown>): string[] => {
const values = [] as string[];
for (const key in enm) {
values.push(enm[key] as string);
}
return values;
};
const x = list(UserRole)
console.log(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment