use Regex here.
```javascript
files[i].match(/[\\\/]metadata\.json$/);
```