r/shittyprogramming • • Jun 07 '21

isEven with regex in javascript

const isEven = n => 'x'.repeat(n).replace(/xx/g, '') === '';
102 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jun 07 '21

Use bigger numbers if you really want to see it slow down :)

2

u/MarceauKa Jun 07 '21

Should I be worried about all these flames around me?