Advertisement
ErolKZ

Untitled

Jan 4th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1.  
  2. function solve(inp) {
  3.  
  4. let start = inp.shift().charCodeAt();
  5.  
  6. let end = inp.shift().charCodeAt();
  7.  
  8. let string = inp.shift();
  9.  
  10. let i = start;
  11.  
  12. let sum = 0;
  13.  
  14.  
  15. while (i <= end) {
  16.  
  17. let curChar = String.fromCharCode(i);
  18.  
  19. if (string.includes(curChar)) {
  20.  
  21. sum += curChar.charCodeAt();
  22.  
  23. }
  24.  
  25. i++;
  26.  
  27. }
  28.  
  29.  
  30. console.log(sum);
  31.  
  32.  
  33.  
  34.  
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement