How to check each item in an array that contains a specific part of a string

function buildEVQuestionLists(category) {

    var items = [];

    var mySurvey = SurveyUtil.Surveys.Get(CurrentPID());
    var remoteQuestions = mySurvey.Questions;

    for (var i = 0; i < remoteQuestions.Count; i++) {
        var question = remoteQuestions[i];
        if (question.IsInCategory(category)) items.push(question.Id);

    }

    return items;

}

This is what return items gives:[EV10013,EV10361,EV10022,EV10009,EV10003,EV10025,EV10020,EV10017,EV10005,EV10000,EV10043,PH10040,PH10013]

Now I would like to go through this list and only return the items that start with ‘EV’.

109 thoughts on “How to check each item in an array that contains a specific part of a string”

  1. 587552 922020Hi there, just became alert to your weblog by means of Google, and discovered that it is truly informative. Im gonna watch out for brussels. Ill be grateful in the event you continue this in future. A great deal of individuals will be benefited from your writing. Cheers! 207233

    Reply

Leave a Comment