I was trying to subtract the last digit out of a string after a loop, but then I found this mysterious phenomenon.
When I add two string of numbers, they concatenate:
"1" + "1" // = "11"
But when I subtract a string of number from another, it did not decatenate but was casted as a number instead:
"11" - "1" // = 10
Why does this happen? Should the result of the subtraction be "1" instead of 10? Wouldn't having some kind of consistency be better?
Edit: This question is NOT a duplicate of the question below, as this question is asking about the subtraction of two strings, instead of a string with a number.
Why does JavaScript handle the plus and minus operators between strings and numbers differently?