I know many programming languages, but one I don't know is Perl. How would I implement the following Perl snippet in Javascript?
my $minGroups = 3;
my %rexGroups = (
upper => qr/[A-Z]/,
lower => qr/[a-z]/,
digit => qr/[0-9]/,
other => qr/^[A-Za-z0-9]/,
);
my $nGroups = 0;
for my $re (keys %rexGroups) {
++$nGroups if ( $pass =~ m/$rexGroups{$re}/ );
}
if ( $nGroups < $minGroups ) {
# indicate error
}
# indicate success