Advertisement
ErolKZ

Untitled

Jan 4th, 2022
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 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 i = start + 1;
  9.  
  10. let sum = 0;
  11.  
  12. let str = '';
  13.  
  14. while (i <= end - 1) {
  15.  
  16. let curChar = String.fromCharCode(i);
  17.  
  18. str += curChar;
  19.  
  20. i++;
  21.  
  22. }
  23.  
  24.  
  25.  
  26. sum = str.split('').reduce((acc, el) => acc + el.charCodeAt(), 0);
  27.  
  28. console.log(str, sum);
  29.  
  30. }
  31.  
  32.  
  33. solve(
  34.  
  35. [
  36.  
  37. '?',
  38.  
  39. 'E',
  40.  
  41. '@ABCEF'
  42.  
  43. ]
  44.  
  45. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement