Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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