Question: For Eq:

```
var str1="IloveLinux";
var str2="weloveNodejs";

```

any function that can return true/value/or any possible flag ?

Answer: 
Well your strings have only one word! In that case you need to check only matching characters between both strings.

**Solution:**

That's the function you need to use to get matching elements:

```
var matchingElements = arr1.filter(function(item) {
      return arr2.indexOf(item) > -1;
});

```

You need to convert your strings to array of characters using `string.split("")`, then loop over these two arrays to find matches.

**Demo**:

```js
var str1 = "IloveLinux";
var str2 = "weloveNodejs";

var arr1 = str1.split("");
var arr2 = str2.split("");

var matchingElements = arr1.filter(function(item) {
  return arr2.indexOf(item) > -1;
});

console.log(matchingElements);
```

**Note:**

This function can be used with words too, if you were comparing words instead of characters you will just need to use `.split(" ")` instead of `.split("")`.
Strings are iterable, so you don't need to convert them to an array to iterate them. You can use an ES6 `for...of` loop , a `for...in` loop if you want to support older browsers, or even just a basic `for(;;){}` loop if you want to support really old browsers.

If you want to return an array of all elements that exist in both strings (not unique), push all matching elements onto an array, then return that array.

```js
const check = (a, b) => {
   const common = []
   for(let l of a) if(b.indexOf(l) >= 0) common.push(l)
   return common
}

console.log(check("IloveLinux", "weloveNodejs")) // ['l','o','v','e']
console.log(check("lllll", "lllll")) // ['l','l','l','l','l']
console.log(check("I love Linux".split(' '), "we love Nodejs".split(' '))) // ['love']
```

If you want to return an array of all *unique* elements that exist in both strings, create an object and use the matching elements as keys while setting the values corresponding to those keys to `true`, then return the result of calling `Object.keys` on that object.

```js
const check = (a, b) => {
   const common = {}
   for(let l of a) if(b.indexOf(l) >= 0) common[l] = true
   return Object.keys(common)
}

console.log(check("IloveLinux", "weloveNodejs")) // ['l','o','v','e']
console.log(check("lllll", "lllll")) // ['l']
console.log(check("I love Linux".split(' '), "we love Nodejs".split(' '))) // ['love']
```

If you only want to return true *if there are any matching elements*, simply return true on the first match and return false otherwise. This method also doesn't require iterating the entire string unless there are no matches, because it will return as soon as it finds a match.

```js
const check = (a, b) => {
   for(let l of a) if(b.indexOf(l) >= 0) return true
   return false
}

console.log(check("IloveLinux", "weloveNodejs")) // true
console.log(check("I love Linux".split(' '), "we love Nodejs".split(' '))) // true
```