I have a variable as amount
.
- If amount has value
10
, then I should console log it as 'integer' - If amount has value
10.5
, then I should console log it as 'float'
I have a variable as amount
.
10
, then I should console log it as 'integer'10.5
, then I should console log it as 'float'The most common way AFAIK is to use the remainder operator:
boolean isFloat = amount % 1 !== 0
This should work in all browsers