Hello guys,
this I’m trying to build a counter project by using javascript from freecodecamp articles.
I don’t know what is wrong with it.
it is only worked when i do copy paste.
when i tried to type the code this is not working.
please help me i’m new to js and this the article im trying .
https://www.freecodecamp.org/news/learn-javascript-by-building-a-project/
1 Like
Can you share the project code, I am not sure how can we help only having a screenshot?
renanb
3
Please, share all the code.
But in one first look, I can guess the problem is you don’t have a counter.
let count = 0;
const value = document.querySelector('#value');
const btns = document.querySelectorAll('.btn');
btns.forEach( function(btn) {
btn.addEventListener("click", function (e) {
const styles = e.currentTarget.classList;
if (styles.contains('decrease')){
count--;
}
else if (styles.contains('increase')) {
count++;
}
else {
count = 0;
}
value.textContent = count;
});
});
This works for me.
1 Like
system
Closed
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.