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 called day = 2
. When I use the code of array.indexOf(day)
, it returns -1
.
Why does this happen?