Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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] + ",";
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading