javascript - Convert data value to decimals? -
i have function argument
called value
. used pass integer value of value
array.
i want take value returns , set 2 decimal places using tofixed(), not sure @ point can this.
function getarrayofitems(value, id, title) { return { size: value }; }; var thedata = [ getarrayofitems(data.average, 'average', 'average'), getarrayofitems(data.smallest, 'smallest', 'smallest'), getarrayofitems(data.largest, 'largest', 'largest') ];
it passed object such
var options = { amount: value, id: id, title: title };
so value determined value of data.average
etc, returns 4 or 5 digit value. want parse value 2 decimal places. possible?
use .tofixed(2)
here
getarrayofitems(data.average.tofixed(2), 'average', 'average'), getarrayofitems(data.smallest.tofixed(2), 'smallest', 'smallest'), getarrayofitems(data.largest.tofixed(2), 'largest', 'largest')
as per question
getarrayofitems((data.average / 100).tofixed(2), 'average', 'average'),
Comments
Post a Comment