Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let textArea = document.getElementById('input');
- let text = textArea.value;
- let splitText = text.split('.');
- let outputTextList = [];
- let outputText = '';
- let counter = 0;
- for (let i = 0; i < splitText.length; i++) {
- if (splitText[i].length >= 1) {
- counter += 1;
- outputText += splitText[i].trimStart() + '.';
- if (counter === 3 || i === splitText.length - 1) {
- outputTextList.push(outputText);
- counter = 0;
- outputText = '';
- }
- }
- }
- if (outputText) {
- outputTextList.push(outputText);
- }
- let output = document.getElementById('output');
- for (const el of outputTextList) {
- let z = document.createElement("p");
- z.innerHTML = el;
- output.appendChild(z);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment