3110-score-of-a-string

DevGod
Vtuber
class Solution { public int scoreOfString(String s) { int score = 0; for (int i = 0; i < s.length() - 1; i++) { score += Math.abs(s.charAt(i) - s.charAt(i + 1)); } return score; }}
/** * @param {string} s * @return {number} */var scoreOfString = function(s) { let score = 0; for(let L = 0; L<s.length-1; L++){ score += Math.abs(s.charCodeAt(L)-s.charCodeAt(L+1)); } return score;};