forked from JSR-2-14/u1_hw_mad_libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (24 loc) · 965 Bytes
/
script.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
const startupX = ['Uber', 'Google', 'Amazon', 'Apple', 'Facebook', 'Twitter', "Meta"];
const startupY = ['Slack', 'Trello', 'Tesla', 'Hyperloop', 'Harvest'];
const favorites = []
let madLib;
let madLibNode;
function clickCreate () {
document.getElementById('xForY').innerText = ""
let random1 = Math.floor((Math.random() * startupX.length));
let random2 = Math.floor((Math.random() * startupY.length));
madLib = 'A startup that is ' + startupX[random1] + ', but for ' + startupY[random2];
madLibNode = document.createTextNode(madLib);
document.getElementById('xForY').appendChild(madLibNode)
}
function clickFav () {
favorites.push(madLib)
}
function clickPrint () {
document.getElementById('favorites').innerText = favorites.toString();
favorites.forEach(fav => {
let h2Node = document.getElementById("favorites")
let textNode = document.createTextNode(fav)
h2Node.appendChild(textNode)
})
}