Advertisement
Spocoman

02. Letters Combinations

Jan 1st, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lettersCombinations(input) {
  2.     let x = input[0].charCodeAt(0);
  3.     let y = input[1].charCodeAt(0);
  4.     let z = input[2].charCodeAt(0);
  5.     let counter = 0;
  6.     let print = '';
  7.     for (let i = x; i <= y; i++) {
  8.         for (let k = x; k <= y; k++) {
  9.             for (let j = x; j <= y; j++) {
  10.                 if (i !== z && k !== z && j !== z) {
  11.                     print += String.fromCharCode(i) + String.fromCharCode(k) + String.fromCharCode(j) + ' ';
  12.                     counter++;
  13.                 }
  14.             }
  15.         }
  16.     }
  17.     console.log(print + counter);
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement