will however output “45” instead, since both counter and i are numbers.
Also, you’re using innerHTML to insert text in quite a few of your snippets. This is however not recommended, as it goes through the HTML parser even though it doesn’t contain any HTML (Even then, you should use DOM functions to insert elements, not innerHTML). Thus, you should use innerText instead.
I’d just like to note a few mistakes you’ve made here:
will output “0123456789”, since
innerHTML
is a string, and thus you’re not addingi
, but appending it.will however output “45” instead, since both
counter
andi
are numbers.Also, you’re using
innerHTML
to insert text in quite a few of your snippets. This is however not recommended, as it goes through the HTML parser even though it doesn’t contain any HTML (Even then, you should use DOM functions to insert elements, notinnerHTML
). Thus, you should useinnerText
instead.Hi Tobias,
you're right. I made a mistake. I upgraded the article. Thanks!
45, not 55
Thanks, I fixed it.