forked from louisrli/recoded-mad-libz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
madlibs.js
49 lines (48 loc) · 1.61 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
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Complete the implementation of parseStory.
*
* parseStory retrieves the story as a single string from story.txt
* (I have written this part for you).
*
* In your code, you are required (please read this carefully):
* - to return a list of objects
* - each object should definitely have a field, `word`
* - each object should maybe have a field, `pos` (part of speech)
*
* So for example, the return value of this for the example story.txt
* will be an object that looks like so (note the comma! periods should
* be handled in the same way).
*
* Input: "Louis[n] went[v] to the store[n], and it was fun[a]."
* Output: [
* { word: "Louis", pos: "noun" },
* { word: "went", pos: "verb", },
* { word: "to", },
* { word: "the", },
* { word: "store", pos: "noun" }
* { word: "," }
* ....
*
* There are multiple ways to do this, but you may want to use regular expressions.
* Please go through this lesson: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/
*/
function parseStory(rawStory) {
// Your code here.
return {}; // This line is currently wrong :)
}
/**
* All your other JavaScript code goes here, inside the function. Don't worry about
* the `then` and `async` syntax for now.
*
* NOTE: You should not be writing any code in the global namespace EXCEPT
* declaring functions. All code should either:
* 1. Be in a function.
* 2. Be in .then() below.
*
* You'll want to use the results of parseStory() to display the story on the page.
*/
getRawStory()
.then(parseStory)
.then((processedStory) => {
console.log(processedStory);
});