@mpmanning108/

Madlibs(3)

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.19532182231812523","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"Ly9NYWRsaWJzOyBjbGljayBydW4gYW5kIGZpbGwgaW4gdGhlIHByb21wdHMuIEVudGVyIGNhbmNlbCB0byBjbG9zZSBhbGwgcHJvbXB0IHdpbmRvd3MuCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgp2YXIgbWFkbGliID0gIkknbSBzbyB7ZW1vdGlvbn0gdGhhdCBJIGNhbid0IGV2ZW4ge3ZlcmIgbm90IGVuZGluZyBpbiBpbmcgb3IgZWR9IHN0cmFpZ2h0LiBMYXN0IHt0aW1lIG9mIGRheX0gbXkge2Z1bm55IGFkamVjdGl2ZX0gYnJvdGhlciB7dmVyYiBlbmRpbmcgd2l0aCBlZH0uIE5vdywgSSBjYW4ndCB7dmVyYn0gYmVjYXVzZSBvZiBoaW0hIFRoZSB7YWRqZWN0aXZlfSBwYXJ0IGlzIGhlIGlzIG9ubHkge251bWJlcn0geWVhcnMgb2xkLCBzbyBJIGNhbid0IGV2ZW4ge2Zvcm0gb2YgcHVuaXNobWVudH0gaGltLiBJIHdpc2ggSSBoYWQgYW4ge2FkamVjdGl2ZX0gYnJvdGhlciB3aG8gZGlkbid0IGRyaXZlIG1lIHthZGplY3RpdmV9LiI7Cgp2YXIgbWFkbGliX3BhdHRlcm4gPSAveyguKz8pfS9nOwoKYmxhbmtzID0gbWFkbGliLm1hdGNoKG1hZGxpYl9wYXR0ZXJuKTsKZm9yKHZhciBpIGluIGJsYW5rcyl7CiAgdmFyIHdvcmQgPSB3aW5kb3cucHJvbXB0KCJHaXZlIG1lIGEgIitibGFua3NbaV0pOwogIAogIGlmICgiY2FuY2VsIj09d29yZCl7YnJlYWt9CiAgCiAgbWFkbGliID0gbWFkbGliLnJlcGxhY2UoYmxhbmtzW2ldLCB3b3JkKTsKfQpjb25zb2xlLmxvZyhtYWRsaWIpOwoK"},"asBuffer":null},"loaded":true}}
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
//Madlibs; click run and fill in the prompts. Enter cancel to close all prompt windows.































var madlib = "I'm so {emotion} that I can't even {verb not ending in ing or ed} straight. Last {time of day} my {funny adjective} brother {verb ending with ed}. Now, I can't {verb} because of him! The {adjective} part is he is only {number} years old, so I can't even {form of punishment} him. I wish I had an {adjective} brother who didn't drive me {adjective}.";

var madlib_pattern = /{(.+?)}/g;

blanks = madlib.match(madlib_pattern);
for(var i in blanks){
  var word = window.prompt("Give me a "+blanks[i]);
  
  if ("cancel"==word){break}
  
  madlib = madlib.replace(blanks[i], word);
}
console.log(madlib);

Native Browser JavaScript