DEV Community

loading...

Discussion on: JavaScript Programming Problem

Collapse
alinp25 profile image
Alin Pisica

I am not sure 100% about correctitude, I wrote it from my phone, but I hope it's doing well.

var alphabetPosition = str => str.split("").map(x => 
    x.match(/[a-z]/i) 
      ? (x.charCodeAt(0) - 96).toString() 
      : '')
    .filter(x => x.length)
    .join(' ');
Enter fullscreen mode Exit fullscreen mode
Collapse
alekseiberezkin profile image
Aleksei Berezkin

That's faster than the original solution

Collapse
hijazi313 profile image
Muhammad Hamza Hijazi Author

it's working correctly <3

Forem Open with the Forem app