I am making a very simple Hook function to help convert Date objects into a DateTime format, and that includes turning the spelled out month into a number (like "Sep" to 9) The Hook I have takes in that 3 character string, and should spit out a number, but instead keeps returning nothing. This is because none of the if or `else if's are being hit,
export default function convertMonthToNumber(mon){
console.log(mon, "MONTH")
if (mon === "Jan"){
return 1
}
else if (mon == "Feb"){
return 2
}
if (mon == "Mar"){
return 3
}
if (mon == "Apr"){
return 4
}
if (mon == "May"){
return 5
}
if (mon == "Jun"){
return 6
}
if (mon == "Jul"){
return 7
}
if (mon == "Aug"){
return 8
}
if (mon == "Sep"){
return 9
}
if (mon == "Oct"){
return 10
}
if (mon == "Nov"){
return 11
}
if (mon == "Dec"){
return 12
}
else{
console.log(mon, "MONTH")
console.log("???")
}
}
Which will print the following...
LOG Sep MONTH
LOG Sep MONTH
LOG ???
And call me a madman, but I firmly believe that "Sep" === "Sep"
Anyone see what's going wrong?