[Solved] What will be a result from var number = “1.2”; console.log(number – 0.2); console.log(number + 0.2);? [duplicate]


The answer will be
1 and
1.20.2 respectively

Note that number is string, but since – operator is not supported by string, JS converts it to number thus the output 1. for the second case, since + operator is supported by string, it will simply concatenate it, hence the answer 1.20.2

solved What will be a result from var number = “1.2”; console.log(number – 0.2); console.log(number + 0.2);? [duplicate]