Skip to content

Commit ff80e60

Browse files
author
Gonzalo Diaz
committed
[BUGFIX] Unexpected negated condition.
Negated conditions should be avoided when an else clause is present typescript:S7735
1 parent fbf8da0 commit ff80e60

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/hackerrank/implementation/migratoryBirds.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ function migratoryBirds(arr: number[]): number {
1717
for (const bird of arr) {
1818
console.debug(`bird ${bird}`);
1919

20-
if (!map[bird]) {
21-
map[bird] = 1;
22-
} else {
20+
if (map[bird]) {
2321
map[bird] += 1;
22+
} else {
23+
map[bird] = 1;
2424
}
2525

2626
console.debug(`bird = ${bird} ~> map[bird] = ${map[bird]}`);

0 commit comments

Comments
 (0)