The [filter() method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) is more appropriate here. the parameter "currTag" has not a good name. This is not a tag the function receives, but an element.