So, here is the thing
console.log('2' - '1')
console.log('2' + '1')
If you have two strings, you can concatenate them with
+. This is not uncommon, many languages do that.
There is no
- operator for strings. So when you use it, it reverts back to the existing
If you want to convert a string (or something that might be a string) to a number, you can use
+x. You need to convert both, because if either is a string, you get concatenation.
console.log( (+'2') + (+'1') ); // logs 3