getRandomInt that takes a minimum and a maximum integer and returns a random integer in the range (minimum: inclusive, maximum: exclusive). The returned random integer is then used to display an item of the array
informationstore that contains information to encourage the HR leadership to have a diverse workforce. The information changes every 3 seconds. After entering the required information, when the user presses the
get insight button, the event listener for click is called. The function prepares the headers & the body. An
xml http request with method
post to the endpoint url, https://api.quickbase.com/v1/records/query is opened. The request header is set. When ready state changes to done, the response text is json parsed and the data is stored in the data variable. Data contains values of requested fields for all rows in the employees table. The length of data array is stored in
totalno variable. The array of objects is then traversed to count the no. of records that fulfill the diversity criteria specified, for instance, where race is equal to black or african american or sex is equal to female. The no. is stored in the variable
totalno, the percent value is calculated. It is compared with required value entered by the user. If percent value is lower than required value the required no. of hires of the specified diversity category is calculated.
var needtohire = ( (requiredvalueindecimal * totalno - diversityno) / (-requiredvalueindecimal + 1) ).toFixed(0);
div is updated with a message to indicate failure in meeting diversity goal along with percent value and hiring advice. If percent value is higher than or equal to required value the result
div is updated with a message to indicate success in meeting diversity goal along with percent value.