Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let text = document.getElementById('input').value.split('.').filter(x => x.length >= 1);
- const output = document.getElementById('output');
- const numberPar = Math.ceil(text.length / 3);
- for (let i = 0; i < numberPar; i++) {
- const paragraph = extract3();
- output.innerHTML += `<p>${paragraph}</p>`;
- }
- function extract3 () {
- let count = 0;
- let result = [];
- while (text.length > 0) {
- if (count == 3) break;
- const sentence = text.shift() + '.';
- result.push(sentence);
- count++;
- }
- return result.join('');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement