8 lines
295 B
TypeScript
8 lines
295 B
TypeScript
export function alphabetPosition(text: string): string {
|
|
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
|
|
const indexArray = [...text]
|
|
.map((char) => alphabet.indexOf(char.toLowerCase()))
|
|
.filter((index) => index !== -1)
|
|
.map((index) => index + 1);
|
|
return indexArray.join(' ');
|
|
} |