Last updated 4 years ago
Was this helpful?
const sumAsciiCodes = (str) => str && (str.length === (str.match(/[a-z]/gi) || '').length) ? [...str.toUpperCase()].reduce((acc, cur) => acc + cur.charCodeAt(0), 0) : 0;