re: TypeError: JavaScript VIEW POST


You can add 1 and 'H' in JS. The 1 gets coerced to a string and the result is '1H'.

Also, the Cannot set property 'innerHTML' of null error has nothing to do with the type of the num variable. document.getElementById("demo") is returning null in this case and setting properties on null throws a TypeError.


Hi Johnny, I got your point. It was my bad.


Yes, you're right.adding a number with an integer will result in JS triggering implicit coercion which will convert the number into string and it will perform concatenation instead. No errors thrown.


Thanks Vyzaldy for bringing this to me. I'll look into it.

code of conduct - report abuse