Web Development Tutorial for Beginners #16 - JavaScript - Click Counter

preview_player
Показать описание
In this javascript web development tutorial we are creating a click counter button that will count up every time you click on a button and we will include a reset button as well.
Рекомендации по теме
Комментарии
Автор

One thing to note that he just sorta skips over is the reason for ++ working and +=1 not working. ++ assumes the value is an integer, += does not. Therefore it treats the innerHTML value as it truly is, a string, and just concatenates onto the value ex: This becomes important if say you wanted to increment or decrement by a value different than 1. You would need to parseInt the innerHTML to turn the string into an integer before manipulating it and then remember to reinclude the path back to where you want to put it. Be careful though, if you use parseInt you need to make sure there is a starting numeric value, so give your counter a starting value in the HTML such as 0 (makes sense) like he does. Otherwise you will get the result NaN (not a number).

ex:

let countNum =

function countUp(){
countNum+=2
= countNum
}

darthscrotius
Автор

Thanks for the tutorial!
Best ever
Hope the next vids including source code 🌿

parryhotter
Автор

thank you for the lesson. I would like to use the counter with other person, and the counter still have the value before refresh

lec
Автор

Hi, thank you for the lesson. I have one problem, when I press the button instead of the numbers going it, NaN just pops up. Could you please help me? Thanks!

vampyauto
Автор

How would I add commas to the count for big numbers?

hopetangunu