Question
Hey there, I need help with this....must be done in JavaScript Write a script that uses random number generation to create sentences. Use five arrays
Hey there, I need help with this....must be done in JavaScript
Write a script that uses random number generation to create sentences. Use five arrays of strings called article, noun, verb and preposition. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period. The arrays should be filled as follows: the article array should contain the articles "the", "a", "one", "some" and "any"; the noun array should contain the nouns "boy", "girl", "dog", "town" and "car"; the verb array should contain the verbs "drove", "jumped", "ran", "walked" and "skipped"; the preposition array should contain the prepositions "to", "from", "over", "under" and "on".
ALSO must include these changes...
1.Capitalize the first letter of each sentence, of course.
2.The logic of the resulting story can't be helped, but the spacing can. Here's an example: "The car ran to the town.Some boy jumped over a car." Correct for it.
3. Keep track of how many times each word is used.
4.The first time a noun is used in the story, it must take the article "a".
5.After a noun has been used, it can no longer use "a". Check my logic here: this requirement means
the first sentence will contain two "a"s (most times), and
we'll only see the word "a" five times (or fewer).
6. At the end of the page, display an alphabetized list of the words available for the story, along with the number of times each was used.
7. There's must be at least 5 arrays somehow
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started