r/shittyprogramming • • Jun 07 '21
isEven with regex in javascript
const isEven = n => 'x'.repeat(n).replace(/xx/g, '') === '';
102
Upvotes
r/shittyprogramming • • Jun 07 '21
const isEven = n => 'x'.repeat(n).replace(/xx/g, '') === '';
View all comments
2
u/SkatingOnThinIce Jun 07 '21
That is great but mine will consider every instance of x in the string: