@mpmanning108/

Madlibs(2)

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5283774019985299","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"Ly9NYWRsaWJzOyBjbGljayBydW4gYW5kIGZpbGwgaW4gdGhlIHByb21wdHMuIEVudGVyIGNhbmNlbCB0byBjbG9zZSBhbGwgcHJvbXB0IHdpbmRvd3MuCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKdmFyIG1hZGxpYiA9ICJPbiB7ZGF5IG9mIHRoZSB3ZWVrfSwgbXkgcGV0IHthbmltYWx9IHt2ZXJiIGVuZGluZyB3aXRoIC1lZH0gbXkgbW9tIHdpdGggaXQncyB7Ym9keSBwYXJ0IG9mIGFuIGFuaW1hbH0uIE15IG1vbSB3YXMgc28ge2Vtb3Rpb259IHRoYXQgc2hlIHt2ZXJiIGVuZGluZyB3aXRoIC1lZH0gaXQgdXAgaW4gYSB0aW55IHthbmltYWx9IGNhZ2UuIFNoZSB0aGVuIHdlbnQgYW5kIHtwYXN0IHRlbnNlIHZlcmJ9IG15IHthZGplY3RpdmV9IGJyb3RoZXIsIGFuZCB0b3JlIHtkaXJlY3Rpb259IG9uZSBvZiB0aGUge2NlbGVicml0eX0gcG9zdGVycyBpbiBoaXMgYmVkcm9vbS4gIEhlIHdhcyBzbyB7ZW1vdGlvbn0gdGhhdCBoZSB7dmVyYiBlbmRpbmcgd2l0aCAtZWR9LiI7Cgp2YXIgbWFkbGliX3BhdHRlcm4gPSAveyguKz8pfS9nOwoKYmxhbmtzID0gbWFkbGliLm1hdGNoKG1hZGxpYl9wYXR0ZXJuKTsKZm9yKHZhciBpIGluIGJsYW5rcyl7CiAgdmFyIHdvcmQgPSB3aW5kb3cucHJvbXB0KCJHaXZlIG1lIGEgIitibGFua3NbaV0pOwogIAogIGlmICgiY2FuY2VsIj09d29yZCl7YnJlYWt9CiAgCiAgbWFkbGliID0gbWFkbGliLnJlcGxhY2UoYmxhbmtzW2ldLCB3b3JkKTsKfQpjb25zb2xlLmxvZyhtYWRsaWIpOwoKdmFyIHNwZWFrID0gd2luZG93LnNwZWVjaFN5bnRoZXNpczsKCnNwZWFrLnNwZWFrKG5ldyBTcGVlY2hTeW50aGVzaXNVdHRlcmFuY2UobWFkbGliKSk7CmFsZXJ0KG1hZGxpYik7CgoKCg=="},"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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//Madlibs; click run and fill in the prompts. Enter cancel to close all prompt windows.


















































var madlib = "On {day of the week}, my pet {animal} {verb ending with -ed} my mom with it's {body part of an animal}. My mom was so {emotion} that she {verb ending with -ed} it up in a tiny {animal} cage. She then went and {past tense verb} my {adjective} brother, and tore {direction} one of the {celebrity} posters in his bedroom.  He was so {emotion} that he {verb ending with -ed}.";

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);

var speak = window.speechSynthesis;

speak.speak(new SpeechSynthesisUtterance(madlib));
alert(madlib);



Native Browser JavaScript