Quiz_dashboard/src/utils/getCharFromNumber.ts
karimaldeen 7aa8d50cfd fix
2024-09-07 12:16:10 +03:00

10 lines
354 B
TypeScript

export function getCharFromNumber(num: number) {
const charCode = num + 97; // Add the number to 97 to get the ASCII code
if (charCode > 122) {
// Check if the resulting code exceeds 'z'
return "Out of range";
}
const character = String.fromCharCode(charCode).toUpperCase(); // Convert the ASCII code to a character
return character;
}