<h1>Your program produced:</h1>
<p id="fill"></p>
<h1>Our program produced:</h1>
<p>Story the happened of a. Port above channel. I tuned was and the. The I. Of burn as such more bit more various more from. Tuned sky. Generally was. Above color more less was. It. Each people. Bit dead pleasure this story a generally the bit bit and. To as pleasure to port the from and and each happens. Various different people. Sky. Each story. Happens and I happens or each. Each the a from it had burn channel the. From all this bit. Channel. And to by. I happened. Port. Happened. Pleasure. Sky to. Pleasure time cases was. Television it was a. Color. Sky. A dead the from. Had above. It as. It the to the a pleasure channel generally burn of and the various to burn was happened sky people. Pleasure was I. It bit. Happened I sky was it in happened all as. Above. This all happens story. Sky the color was above cases people the above or each this to the the by to various was or the was people. Happened. From. In story a happened to. Happened sky it people. To bit all generally cases. To. Happens</p>
JavaScript
/* Lorem Ipsum Generator
Lorem Ipsum filler text is often used to mock how a page might look with real-looking text.
Your task is to create a program that generates filler text like you can see that our program
produced by changing the function "generateIpsum()" below.
The source for the filler words must come from the variable "words" to produce about 1000
characters of output.
The time limit for this task is 20 minutes. If you run out of time, it is sufficient to
explain how your solution is better or worse than the output of our program and how you
would improve it if you had more time.
Send the contents of this pane and the contents of the Result pane as text files when done.
*/
var words = "The sky above the port was the color of television, tuned to a dead channel. All this happened, more or less. I had the story, bit by bit, from various people, and, as generally happens in such cases, each time it was a different story. It was a pleasure to burn.";
// Variable to set the length of the words to be generated.
var generatedLength = 1000;
function generateIpsum() {
var splittedWords = words.split(' ');
var result = '';
var needCapitalizing = false;
var max = splittedWords.length-1;
for (var i = 0; i<generatedLength; i++)
{
var randomIndex = getRandomInt(0, max);
// If its the first word or if the previous word had a period then we want the word to be capitilized.
if (needCapitalizing || i === 0 )
{
result += capitalize(splittedWords[randomIndex]) + ' ';
needCapitalizing = false;
}
else
{
// if not then the word needs to be in lower case.
result += splittedWords[randomIndex].toLowerCase() + ' ';
// if the current word has a period then we need that the next word to be capitalized.
if (splittedWords[randomIndex].indexOf('.') > -1)
{
needCapitalizing = true;
}
}
// if we are on the last word to be generated,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.