-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmadlibs.js
40 lines (23 loc) · 2.29 KB
/
madlibs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//START HERE:
// 0. Run the 'Sample Mad Libs Story` code below and see how the example works.
// 1. Start off by writing a straight forward story (3-4 sentences) using comments. If you need inspiration: write about what you did this morning, or what you did this weekend. No need to get hung up on the details: you can also use the standard "Once upon a time..." intro for inspiration.
// 2. Now select 2-3 key words from your story. Be sure to sure to remember which parts of the story the words you selected are from.
// 3. Next, create a variable for each of the key words you've selected. Since you don't want to give away how they fit into the story, consider naming them based on their part of speech (such as `verb1` or `nounPlural2)`. Set each one equal to a prompt that the user can answer.
// 4. Code `console.log()` statements for each sentence of your story. Make sure to add in the variables to the strings in your `console.log()` statements. Use concatenation or string formatting to insert each variable's value into your sentences.
// 5. Run your code to see if everything works.
// 6. Repeat until your story requires at least five words provided by your user. You can add sentences to your story as necessary.
// 7. Send a link to your running code to someone else to test out.
// 0. Sample Mad Libs Story:
// Press `Run` to see how this Mad Libs lab is meant to work!
// You can make this sample code a comment once you've tested it.
// Initialize a variable that prompts a User to input a noun below:
let examplePropNoun = prompt("Please enter a proper noun (person's name):");
let exampleAdjective = prompt("Please enter an adjective (describes a noun or pronoun):");
let exampleNoun = prompt("Please enter a noun that is a place: ")
// Example story
console.log("Once upon a time " + examplePropNoun + " woke up in an enchanted forest.");
console.log("There were " + exampleAdjective + " creatures all around!");
console.log("'Oh no!', said " + examplePropNoun + " 'I must return to " + exampleNoun + " immediately!'")
// 1. Draft your 3-4 sentence story below using comments:
// 2 & 3. Once you've selected 2-3 keywords in your story, initialize you variables below:
// 4. Code `console.log()` statements for each statement of your story below. Remember to concatenate the variables in step 3 where needed.