-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7119bb
commit 0868c19
Showing
6 changed files
with
411 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
function helloCoderIpsum() { | ||
console.log('Coder Ipsum worked') | ||
const sampleSize =require('lodash/sampleSize') | ||
const words = require('./words.json') | ||
|
||
function getRandomInt(min = 3, max = 5) { | ||
return Math.floor(Math.random() * (max - min + 1)) + min | ||
} | ||
|
||
// Returns a String of a set of unformatted coder ipsum "words". Note that some words are more than one word like "Lil' Bobby Tables". | ||
function phrase(numWords = getRandomInt(6, 10)) { | ||
return sampleSize(words, numWords).join(' ') | ||
} | ||
|
||
// Returns a String of a set of coder ipsum "words" in the format of a sentence - with capitalization and period punctionation. Note that some words are more than one word like "Lil' Bobby Tables". | ||
function sentence(numWords = getRandomInt(6, 10)) { | ||
const unformatted = phrase(numWords) | ||
return unformatted.charAt(0).toUpperCase() + unformatted.slice(1) + '.' | ||
} | ||
|
||
// Returns a String of a set of coder ipsum "words" in the format of a paragraph with multiple sentences - with capitalization and period punctionation. Note that some words are more than one word like "Lil' Bobby Tables". | ||
function paragraph(numSentences = getRandomInt(3, 5)) { | ||
const sentenceArray = new Array(numSentences).fill().map(element => { | ||
return sentence() | ||
}) | ||
return sentenceArray.join(' ') | ||
} | ||
|
||
module.exports = helloCoderIpsum() | ||
module.exports = { | ||
phrase, | ||
sentence, | ||
paragraph | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const coderIpsum = require('./index') | ||
|
||
console.log("Invoking phrase with no number of words set..."); | ||
console.log(coderIpsum.phrase()); | ||
|
||
console.log("Invoking phrases of 5 words..."); | ||
console.log(coderIpsum.phrase(5)); | ||
|
||
console.log("Invoking sentence with no length set..."); | ||
console.log(coderIpsum.sentence()); | ||
|
||
console.log("Invoking sentence with 8 words..."); | ||
console.log(coderIpsum.sentence(8)); | ||
|
||
console.log("Invoking paragraph with no length set..."); | ||
console.log(coderIpsum.paragraph()); | ||
|
||
console.log("Invoking paragraph with 2 sentences..."); | ||
console.log(coderIpsum.paragraph(2)); |
Oops, something went wrong.