- Joined
- Sep 15, 2012
- Messages
- 102
- Reaction score
- 60
- First Language
- Portuguese
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!
Last edited by a moderator:
