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’.

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

Leave a Comment