Skip to content

Commit ffe9229

Browse files
committed
add working explode functionality
1 parent b56e8a1 commit ffe9229

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

chapter_fifteen_balloon/script.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ function explode() {
1515
balloon.innerText = "💥";
1616
}
1717

18-
window.addEventListener('keydown', (e) => {
19-
console.log(e.key);
18+
function controlSize(e) {
2019
if (e.key == `ArrowUp`) {
2120
inflate();
2221
} else if (e.key = 'ArrowDown') {
2322
deflate();
23+
}}
24+
25+
window.addEventListener('keydown', controlSize);
26+
27+
window.addEventListener('keydown', () => {
28+
let currentSize = Number(balloon.style.fontSize.match(/\d+/g))
29+
if (currentSize > 240) {
30+
explode();
31+
window.removeEventListener('keydown', controlSize);
2432
}
2533
})
2634

0 commit comments

Comments
 (0)