-1

I want to display value of integer variable as 8.0 , but the output show only 8

var c = 8.0;
console.log(c);

Output: 8

2 Answers2

2

you can use toFixed

console.log(c.toFixed(1));
Littlee
  • 3,791
  • 6
  • 29
  • 61
0

If you want to display it with the decimal you can use var c = 8.0; c.toFixed(1) which would output 8.0

Tony Tai Nguyen
  • 1,502
  • 13
  • 27