I have an array of numbers containing 1-20. When I use the indexOf method to try to find the position of "2", it shows up at the 3rd position (correct).
I have a variable calledday = 2
. When I use the code ofarray.indexOf(day)
, it returns-1
.
Why does this happen?