Advertisement
bebo231312312321

Untitled

Mar 18th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function rageQuit (input){
  2.     let regexString = /[^0-9]+/g;
  3.     let regexNum = /[0-9]+/g;
  4.  input=input.shift()
  5.    
  6.     let finalString = '';
  7.     let uniqueSymbols = {};
  8.     let txt = input.match(regexString);
  9.     let num = input.match(regexNum);
  10.  
  11.     for(let i = 0; i < txt.length; i++){
  12.         if( txt !==null&& num !==null){
  13.         let a = txt[i].toUpperCase();
  14.  
  15.         for (let el of a){
  16.             uniqueSymbols[el] = 0;
  17.         }
  18.  
  19.         let addToFinalString = '';
  20.         for(let j = 1; j <= Number(num[i]); j++) {
  21.             addToFinalString += a;
  22.         }
  23.         finalString += addToFinalString;
  24.     }
  25. }
  26.     let finalUniqueSymbols = Object.keys(uniqueSymbols);
  27.  
  28.     console.log(`Unique symbols used: ${finalUniqueSymbols.length}`);
  29.     console.log(finalString);
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement