Is there any native or neat way to easily convert number to string and give a sign to it?
for example:
100 --> "+100"
-10 --> "-10"
I wanted to add a signal to the string for both negative and positive.
Thank you in advanced.
EDIT:
value = (value < 0) ? value.toString() : '+' + value;Came up with this!! it works 🙂
EDIT2:
value = (value < 0 ? '' : '+') + value;even more compact, think it is a great utility function!
for example:
100 --> "+100"
-10 --> "-10"
I wanted to add a signal to the string for both negative and positive.
Thank you in advanced.
EDIT:
value = (value < 0) ? value.toString() : '+' + value;Came up with this!! it works 🙂
EDIT2:
value = (value < 0 ? '' : '+') + value;even more compact, think it is a great utility function!