-1
var leter= "trypanosomiasis";

console.log(parseInt(leter));

I tried the code above and the one below

var leter= "trypanosomiasis";
console.log(Number(leter));

None of them seemed to work

ZombieChowder
  • 1,187
  • 12
  • 36

1 Answers1

0

Not sure if this is what you need. Wrote a one-line function that sums all the character's ascii representation in a string. It splits the string into an array of characters and sum them up...

function sumASCII(inputString){
    return inputString.split('').reduce((sum, character)=>{ return sum + character.charCodeAt(0)}, 0);
}

console.log(sumASCII("abcd"));
Hanzhao Deng
  • 118
  • 6