Trying to get my script to count the number of "YES" answered for my variables...

calvin_mckenzie
Tera Contributor
var yesCount = 0;
for (var i = 0; i < variables.length; i++) {
// var question = variables[i].item_option_new;  // Replace 'question' with the actual field name for the question
var answer = variables[i].value;      // Replace 'answer' with the actual field name for the answer
if (answer.toLowerCase() === 'yes') {
yesCount++;
}
}
// 'yesCount' now contains the number of 'yes' answers
 
// Function to update count and check if it's less than 4
function updateCountAndCheck() {
yesCount++;
getTotal(yesCount);
 
if (yesCount > 4) {
return 'Score>4';
        //gs.info("Score>4");
//Your additional GlideScript code here for when count is more than 4
} else {
return 'Score<=4';
//gs.info("Score<=4");
//Your additional GlideScript code here for when count is 4 or less
}
}
 
 
0 REPLIES 0