Very good tips, thank you! I should've noticed includes and when I can use const. Actually, in my day 7 code (bags...) I use includes!
Thank you also for that code sample! I didn't know you can assign the groups into variables like that. 👍
A question which is either "hey, I'm able to give you a suggestion too!" OR there's some optimization magic going on that I don't know about. About the regex, you have:
/(\d*)-(\d*) (\w): (\w*)/g,
Is there a reason why you use * instead of +? Why not:
/(\d)-(\d) (\w): (\w+)/g,
(or \d+ in case the numbers are double or more digits)
Very good tips, thank you! I should've noticed
includes
and when I can useconst
. Actually, in my day 7 code (bags...) I useincludes
!Thank you also for that code sample! I didn't know you can assign the groups into variables like that. 👍
A question which is either "hey, I'm able to give you a suggestion too!" OR there's some optimization magic going on that I don't know about. About the regex, you have:
/(\d*)-(\d*) (\w): (\w*)/g,
Is there a reason why you use
*
instead of+
? Why not:/(\d)-(\d) (\w): (\w+)/g,
(or \d+ in case the numbers are double or more digits)
Thanks for noticing it! It's true that I could've used
+
instead of*
!About maintaining
\d
, I didn't see if the file has values with more than 1 digit, but with*
or+
will cover it! 😄It's just a habit using
*
instead of+
and maybe it could be optimized as you said!