Get round off result

Kinston
Kilo Contributor

Is there a way to get round off the result after below code. 

var count= gr.getRowCount();

while(gr.next())
{
totalAttendance = totalAttendance + gr.u_count;
}

data.wholeCount= totalAttendance /count;

 

As of now I am getting the result in a decimal form.

1 ACCEPTED SOLUTION

Shubham Tipnis
Kilo Sage
Kilo Sage

Hi Kinston,

 

Just use Math.round to get round off result.

 

var count= gr.getRowCount();

while(gr.next())
{
totalAttendance = totalAttendance + gr.u_count;
}

data.wholeCount= Math.round(totalAttendance/count);

 

Please mark correct/helpful if applicable.

 

Regards,

Shubham

Regards,
Shubham Tipnis
 ServiceNow Enthusiast
️ 3x Rising Star (2022–2024) – ServiceNow Community
 Sharing insights, use cases & real-world learnings from the Now Platform
 Always learning. Always building.

View solution in original post

1 REPLY 1

Shubham Tipnis
Kilo Sage
Kilo Sage

Hi Kinston,

 

Just use Math.round to get round off result.

 

var count= gr.getRowCount();

while(gr.next())
{
totalAttendance = totalAttendance + gr.u_count;
}

data.wholeCount= Math.round(totalAttendance/count);

 

Please mark correct/helpful if applicable.

 

Regards,

Shubham

Regards,
Shubham Tipnis
 ServiceNow Enthusiast
️ 3x Rising Star (2022–2024) – ServiceNow Community
 Sharing insights, use cases & real-world learnings from the Now Platform
 Always learning. Always building.