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("")`.
You could check each sub string and check against the second string with counting the occurence in an object with the substring as key.

```js
var str1 = "IloveLinux",
    str2 = "weloveNodejs",
    common = Object.create(null),
    i, j,
    part;

for (i = 0; i < str1.length - 1; i++) {
    for (j = i + 1; j <= str1.length; j++) {
        part = str1.slice(i, j);
        if (str2.indexOf(part) !== -1) {
            common[part] = true;
        }
    }
}

console.log(Object.keys(common));
```

```css
.as-console-wrapper { max-height: 100% !important; top: 0; }
```