10 lines
271 B
JavaScript
10 lines
271 B
JavaScript
|
export function setupCounter(element) {
|
||
|
let counter = 0;
|
||
|
const setCounter = (count) => {
|
||
|
counter = count;
|
||
|
element.innerHTML = `count is ${counter}`;
|
||
|
};
|
||
|
element.addEventListener('click', () => setCounter(counter + 1));
|
||
|
setCounter(0);
|
||
|
}
|