Why not working?
Hello,
I am wondering why this is not working?
https://codepen.io/lanszelot/pen/qEBOGYQ
17 Replies
because the value is a string
What's not working? What do you think it should be doing?
he wants to show the value in decimal, binary and stuff
but
.value
returns a string-# Dude, I'm trying to teach them #How To Ask Good Questions :p
It's not like we should just tell them that line three should be
And be done. It's a teaching moment!
oh, sorry
😜
the problem with that property is that it is pretty obscure
if you look for the documentation, it's pretty hidden
Really, though, the takeaway is that almost everything in HTML land is a string and if you want another data type you need to convert it in JS
yup
next time, i will hold on my horses and not answer before the question is properly written
Nah, it's all good. I know most people don't read the pinned message before posting >_<
If we waited for a well-formed question nothing would ever get answered 🤣 😭
luckly, this one was pretty obvious and the code wasnt 50000 lines long
I thought if in HTML I add the input type as number the value will be number not string
it's always a string
always
from js side
I see, thank you
that's why the number field has this property