ServiceNow ITSM

Community Alums
Not applicable

Hello Team,

 

I am writing below program in Background script to count of Vowels in Given string , I am not able to run this program. not getting any count . Please help me to correct this 

 

 var str='servicenow fundamentals'
  var vowels = "aeiouAEIOU";
  var count = 0;
  for ( i = 0; i < str.length; i++) {
    if (vowels.includes(str[i])) {
      count++;
    }
  }



1 ACCEPTED SOLUTION

Viraj Hudlikar
Tera Sage

Hello @Community Alums 

When you want to print anything in background script use gs.print();  Check below code and run in your background script.

 

var str = 'servicenow fundamentals';
var vowels = "aeiouAEIOU";
var count = 0;
for (var i = 0; i < str.length; i++) {
    if (vowels.includes(str[i])) {
        count++;
    }
}
// Print the count of vowels 
gs.print('Number of vowels: ' + count);

 

 

VirajHudlikar_0-1737708995105.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

View solution in original post

1 REPLY 1

Viraj Hudlikar
Tera Sage

Hello @Community Alums 

When you want to print anything in background script use gs.print();  Check below code and run in your background script.

 

var str = 'servicenow fundamentals';
var vowels = "aeiouAEIOU";
var count = 0;
for (var i = 0; i < str.length; i++) {
    if (vowels.includes(str[i])) {
        count++;
    }
}
// Print the count of vowels 
gs.print('Number of vowels: ' + count);

 

 

VirajHudlikar_0-1737708995105.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.