Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function asciiSumator(input) {
- let firstChar = input.shift();
- let secondChar = input.shift();
- let str = input.shift();
- let start = Math.min(firstChar.charCodeAt(0), secondChar.charCodeAt(0));
- let end = Math.max(firstChar.charCodeAt(0), secondChar.charCodeAt(0));
- let sum = 0;
- for (let i = 0; i < str.length; i++) {
- let charCode = str.charCodeAt(i);
- if (charCode > start && charCode < end) {
- sum += charCode;
- }
- }
- console.log(sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement