I have a variable
var number = 1;
I'm then trying to add a 2 onto a number but not add them together like this.
1 + 2 = 2
but instead I want, to join 2 onto the number so i would get
12
You can use +=
and add 2 as string then again convert it to number
var number = 1;
number += '2';
console.log(Number(number));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With