Scrollspy: minor refactoring (#35512)
Scrollspy: minor refactoring (#35512)

* reorder variables
* join lines
* use `filter(Boolean)` since it's clearer
* use `for...of`
coliff/bootstrap,m5o/bootstrap,coliff/bootstrap,twbs/bootstrap,tjkohli/bootstrap,twbs/bootstrap,inway/bootstrap,m5o/bootstrap,tjkohli/bootstrap,inway/bootstrap,inway/bootstrap