We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to find the minimum value present in an array?

kutvaram
Tera Expert

Hi All,

I have an array with some values in it.

How to find the minimum value in it?

Suggestions.

Thanks,

Ram

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi Ram,

I assume the values you are having in the array are the integer values or float values

so here is the script; test this in background script and it works in global and custom scope as well and for both integer and float

var array = [20,30];
var min = Math.min.apply(Math, array);

gs.info(min);

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron

Hi Ram,

I assume the values you are having in the array are the integer values or float values

so here is the script; test this in background script and it works in global and custom scope as well and for both integer and float

var array = [20,30];
var min = Math.min.apply(Math, array);

gs.info(min);

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader