2021年4月3日星期六

Replace letters in string with numbers

I have this string '=F*G'

I want to replace it to numbers to be '=6*7'

I have successfully managed to replace letters with number using this code

    var string = '=F*G'          .toLowerCase().split('')          .filter(c => c >= 'a' & c <= 'z')          .map(c => c.charCodeAt(0) -  'a'.charCodeAt(0) + 1)          .join(' ')        console.log(string);

but this code removes the '=' and '*' I need help keeping them in string after replacing letters with numbers

https://stackoverflow.com/questions/66937873/replace-letters-in-string-with-numbers April 04, 2021 at 11:52AM

没有评论:

发表评论