anvil/striker-ui/lib/sumstring.ts

12 lines
212 B
TypeScript

const sumstring = (value: string): number => {
let sum = 0;
for (let index = 0; index < value.length; index += 1) {
sum += value.codePointAt(index) || 0;
}
return sum;
};
export default sumstring;