-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,255
  • 6
  • 23
  • 48
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,394
  • 12
  • 26