0

I take data from Spreadsheet, So I use the below formula in App script Now the data in spreadsheet value=2.33344443333 Hence in HTML same 2.33344443333 it's showing when i call emailTemp.data, Please help me to change to have only 2 decimal value like 2.33

Appscript:

data.forEach(function(row){
  emailTemp.data=row[value];
}
Moses
  • 214
  • 1
  • 4
  • 12

2 Answers2

3

.toFixed(2) would round a decimal value to two spaces as a string. Presumably the following would work if you didn't need to access the value as a decimal later on:

data.forEach(function(row){
  emailTemp.data=row[value].toFixed(2);
}
JFoxx64
  • 262
  • 2
  • 11
0

Try this :

data.forEach(function(row){
  emailTemp.data = Math.round(Number(row[value]) * 100) / 100;
}
batman567
  • 826
  • 2
  • 12
  • 23