Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. (() => {
  2.  
  3. const str = 'v13.9.0, v12.16.1, v11.15.0, v10.19.0, v9.11.2, v8.17.0, v7.10.1, v6.17.1, v5.12.0, v4.9.1';
  4.  
  5. const max_chars = 25;
  6.  
  7. let tail = max_chars;
  8. let comma_found = null;
  9.  
  10. let lines = [];
  11.  
  12. while (tail < str.length){
  13. for (let i = tail; i < 0 || !comma_found; i -=1){
  14. if (str[i] === ','){
  15. comma_found = true;
  16. lines.push(str.slice(tail - max_chars, i + 1));
  17. }
  18. }
  19. comma_found = false;
  20. tail += max_chars;
  21. }
  22.  
  23. const result = lines.join('\n');
  24. console.log(result);
  25.  
  26. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement