indexOf Function III : Variant. Sending in TWO parameters to the function that does the check -- params series, grade. Prior, this function only took one parameter and was sending in pre-defined variables. • Returns ○ e.g., var seriesGradeCheck = seriesFormatter("scion-tc", "TC"); -- TC exists within the string ○ e.g, var seriesGradeCheck = seriesFormatter("scion-tc", "XLE"); -- XLE does not exist within the string.
function seriesFormatter (series, grade) {
var result;
if (series.indexOf(grade.toLowerCase()) >= 0) {
var result = grade + " exists within the string";
} else {
var result = grade + " does not exist within the string";
}
return result;
}
var seriesGradeCheck = seriesFormatter("scion-tc", "tc");
//alert(seriesFormatter(gradeLevel));
document.write(seriesGradeCheck);