js/script.js
// Generate random paragraphs and append them to the page
Generate random paragraphs and append them to the page
Generate random paragraphs and append them to the page
function generateIpsum(explicit = true) {
		const quoteList = window.__TASWELL_QUOTES__;
		const newElements = document.createDocumentFragment();
		const quotes = quoteList.vanilla.concat(explicit ? quoteList.explicit : []);
		const numParagraphs = inputParagraphs.value;
		const numSentences = 10;
		shuffle(quotes);
		results.innerHTML = '';
		for (let i = 0, q = 0; i < numParagraphs; i++) {
			let string = i === 0 ? 'Hey everybody, it\'s Tuuuuuuuesday! ' : '';
			for (let j = 0; j < numSentences; j++, q++) {
				if (!quotes[q]) {
					shuffle(quotes);
					q = 0;
				}
				string += quotes[q] + ' ';
			}
			const p = document.createElement('p');
			p.innerHTML = string;
			newElements.appendChild(p);
		}
		results.appendChild(newElements);
	}
function generateIpsum ( explicit = true ) { const quoteList = window . __TASWELL_QUOTES__ ; const newElements = document . createDocumentFragment ( ) ; const quotes = quoteList . vanilla . concat ( explicit ? quoteList . explicit : [ ] ) ; const numParagraphs = inputParagraphs . value ; const numSentences = 10 ; shuffle ( quotes ) ; results . innerHTML = '' ; for ( let i = 0 , q = 0 ; i < numParagraphs ; i ++ ) { let string = i === 0 ? 'Hey everybody, it\'s Tuuuuuuuesday! ' : '' ; for ( let j = 0 ; j < numSentences ; j ++ , q ++ ) { if ( ! quotes [ q ] ) { shuffle ( quotes ) ; q = 0 ; } string += quotes [ q ] + ' ' ; } const p = document . createElement ( 'p' ) ; p . innerHTML = string ; newElements . appendChild ( p ) ; } results . appendChild ( newElements ) ; }
Generate random paragraphs and append them to the page
Generate random paragraphs and append them to the page
// Iterator for number of paragraphs // Iterator for number of sentences in a paragraph // When we run out of quotes, shuffle the array again and start over