compare names and return the names of ones missing in string – Jquery

I have this question.
Imagine I have this

var1 = ‘october, november, december’
var2 = ‘november’

I want to compare each and then having the output of the names that are not found in each vars comparison. In this case I want to output in another var, ‘october, december’

Is there any way to return that? All I see is true or false options

Edit: It seems I cannot comment posts. No reputation.But im talking about strings.

>Solution :

Probably you can use something like this.

var input = "jan,feb,mar";
var searchTerm = "feb";

var inputArr = input.split(",");
var output = "";
$.each(inputArr, function(i, v){
    if(v != searchTerm)
        output += inputArr[i] + ",";

Leave a Reply