Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function charactersinRange(char1, char2) {
- let start = char1.charCodeAt(0);
- let end = char2.charCodeAt(0);
- let result = "";
- if (start <= end) {
- for (let i = start + 1; i < end; i++) {
- result += String.fromCharCode(i) + " ";
- }
- } else {
- for (let i = start - 1; i > end; i--) {
- result = String.fromCharCode(i) + " " + result;
- }
- }
- console.log(result.trim());
- }
Advertisement
Add Comment
Please, Sign In to add comment