krustev_84

Untitled

Oct 2nd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. function serializeString(input) {
  2.  
  3. let indexes = [];
  4.  
  5. for (let i = 0; i < input.length; i++) {
  6. let currentLetter = input[i];
  7.  
  8. for (let j = 0; j < input.length; j++) {
  9. if (currentLetter === input[j]) {
  10. indexes.push(j)
  11. }
  12. }
  13.  
  14. console.log(`${currentLetter}:${indexes.join('/')}`);
  15. indexes = [];
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment