###Why doing it this way?
We could iterate from \$1\$ to \$100\$ and test each number with /2/.test(n)
, which is a rather concise statement. But in this scenario, we'd have to handle empty entries with something like (/2/.test(n)?'':...)
, which adds a couple more bytes.
For example, this would work for 45 bytes:
f=(n=1)=>n>99?n:(/2/.test(n)?'':[n,,])+f(n+1)
It turns out to be shorter to skip all values of \$n\$ that contain a \$2\$.
###Commented