diff --git a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js index af608eb6..f25af2c0 100644 --- a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js +++ b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js @@ -3,14 +3,19 @@ function increment(node) { let current = node.textContent; node.textContent = Number(current) + 1; } - +function decrement(node) +{ + let current = node.textContent; + node.textContent = Number(current) - 1; +} export function App() { const body = document.createElement("body"); const header = document.createElement("header"); header.innerHTML = `

Number Counter

-

A simple counter. Press increment to increase the count by one.

+

A simple counter. Press increment to increase the count by one and + Press decrement to decrease the count by on.

`; body.appendChild(header); @@ -18,14 +23,20 @@ export function App() { main.innerHTML = `

0

+ `; body.appendChild(main); - + /* const decrementButton = document.createElement("decrementButton"); + decrementButton.innerHTML = ``; + main.appendChild(decrementButton); */ const button = body.querySelector("#increment"); const counter = body.querySelector("#counter"); button.addEventListener("click", () => { increment(counter); }); - + const decBtn =body.querySelector("#decrement"); + decBtn.addEventListener("click", ()=>{ + decrement(counter); + }); return body; }