Advertisement
Guest User

FormatText

a guest
Jan 27th, 2021
1,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2.     let inputStr = document.getElementById('input').value;
  3.     let output = document.getElementById('output');
  4.  
  5.     let input = inputStr.split('.').filter((p) => p.length > 0);
  6.  
  7.     for (let i = 0; i < input.length; i += 3) {
  8.         let arr = [];
  9.         for (let y = 0; y < 3; y++) {
  10.             if (input[i + y]) {
  11.                 arr.push(input[i + y]);
  12.             }
  13.         }
  14.         let paragraph = arr.join('. ') + '.';
  15.         output.innerHTML += `<p>${paragraph}</p>`;
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement