Skip to content

Instantly share code, notes, and snippets.

@toolness
Created February 2, 2013 19:41
Show Gist options
  • Select an option

  • Save toolness/4698951 to your computer and use it in GitHub Desktop.

Select an option

Save toolness/4698951 to your computer and use it in GitHub Desktop.
Jessica B. Ipsum
<!DOCTYPE html>
<meta charset="utf-8">
<title>Jessica B. Ipsum</title>
<style>
#myinput {
background: pink;
}
</style>
<h1>Vocabulary</h1>
<ul id="vocabulary">
<li>nike <em>plus</em></li>
<li>persona</li>
<li>user flow</li>
<li>awesome</li>
<li>co-create</li>
<li>collaborate</li>
</ul>
<div id="result"></div>
<script>
onload = function() {
var vocabulary = window.document.querySelector("#vocabulary");
var NUM_TOTAL_WORDS = 15;
var i = 0;
var sentence = "";
while (i < NUM_TOTAL_WORDS) {
var random = Math.random();
var listIndex = Math.floor(random * vocabulary.children.length);
var randomWord = vocabulary.children[listIndex].textContent;
//console.log("i am computing word number", i, randomWord);
sentence = sentence + randomWord + " ";
i = i + 1;
}
sentence = sentence[0].toUpperCase() + sentence.slice(1, -1) + ".";
console.log(sentence);
document.querySelector("#result").textContent = sentence;
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment