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
0 parents
commit 1db26a0
Showing
1 changed file
with
29 additions
and
0 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,29 @@ | ||
let messageComponents = { | ||
subject: ["You", "Your dad", "Your mum", "Your partner"], | ||
verb: ["will", "will not", "should", "should not", "may", "must", "must not"], | ||
ending: ["enter the mangrove.", "find love among the stars.", "rejoin Satan´s mission.", | ||
"make peace with Saruman."] | ||
}; | ||
|
||
|
||
const messageGenerator = () => { | ||
let subjectLength = messageComponents.subject.length; | ||
let verbLength = messageComponents.verb.length; | ||
let endingLength = messageComponents.ending.length; | ||
|
||
|
||
|
||
let subjectIndex = Math.floor(Math.random() * subjectLength); | ||
let verbIndex = Math.floor(Math.random() * verbLength); | ||
let endingIndex = Math.floor(Math.random() * endingLength); | ||
|
||
|
||
let randomMessage = messageComponents.subject[subjectIndex] + " " + messageComponents.verb[verbIndex] + " " + messageComponents.ending[endingIndex]; | ||
return randomMessage; | ||
|
||
}; | ||
|
||
messageGenerator() | ||
|
||
|
||
|