Skip to content

Commit 5854c78

Browse files
author
Gonzalo Diaz
committed
[BUGFIX] SonarQube: Unexpected negated condition.
Negated conditions should be avoided when an else clause is present javascript:S7735
1 parent 530b779 commit 5854c78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/hackerrank/implementation/migratoryBirds.js

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

19-
if (!map[bird]) {
20-
map[bird] = 1;
21-
} else {
19+
if (map[bird]) {
2220
map[bird] += 1;
21+
} else {
22+
map[bird] = 1;
2323
}
2424

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

0 commit comments

Comments
 (0)