-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (24 loc) · 1.02 KB
/
index.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
//document.getElementById("count-el").innerText=5
// 1. Grab the save-el paragrah and store it in a variable called saveEl
let saveEl = document.getElementById("save-el")
// intialize the count as 0
// listen for clicks on the increment button
// increment the count variable when the button is clicked (log it out)
// change the count-el in the HTML to reflect the new count
let countEL = document.getElementById("count-el")
let count =0
function increment(){
// document.getElementById("count-el").innerText = count
count += 1
countEL.textContent = count
}
// 1. Create a function, save(), which logs out the count when it's called
function save(){
// 2. Create a variable that contains both the count and the dash separator, i.e. "12 - "
let countStr = count + " - "
// 3. Render the variable in the saveEl using innerText
saveEl.textContent += countStr
// NB: Make sure to not delete the existing content of the paragraph
countEL.textContent = 0
count = 0
}