Advertisement
Guest User

Untitled

a guest
Mar 15th, 2022
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lettersCombinations(input) {
  2.  
  3.     let startLetter = input[0].charCodeAt();
  4.     let endLetter = input[1].charCodeAt();
  5.     let exceptLetter = input[2].charCodeAt();
  6.     result = "";
  7.     let validCombinationsCount = 0;
  8.  
  9.     for (let i = startLetter; i <= endLetter; i++) {
  10.         //result += String.fromCharCode(i) + " ";
  11.  
  12.         if (i === exceptLetter) {
  13.             continue;
  14.         }
  15.  
  16.         for (let j = startLetter; j <= endLetter; j++) {
  17.             //result += String.fromCharCode(j) + " ";
  18.  
  19.             if (j === exceptLetter) {
  20.                 continue;
  21.             }
  22.  
  23.             for (let k = startLetter; k <= endLetter; k++) {
  24.                // result += String.fromCharCode(k) + " ";
  25.  
  26.                 if (k === exceptLetter) {
  27.                     continue;
  28.                 }
  29.                 result += String.fromCharCode(i) + String.fromCharCode(j) + String.fromCharCode(k) + " ";
  30.                 validCombinationsCount++;
  31.             }
  32.             //result += validCombinationsCount;
  33.             //console.log(result);
  34.         }
  35.     }
  36.     result += validCombinationsCount; //outside for loop
  37.     console.log(result);              //outside for loop
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement