Skip to content

Commit c54c122

Browse files
committed
remove console BinaryGap.js
1 parent 09175e5 commit c54c122

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

lesson1_iterations/BinaryGap.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
function solution(N) {
2-
let max = 0;
3-
let counter = 0;
4-
const binary = N.toString(2);
5-
for (let i = 0; i < binary.length; i++) {
6-
if (binary[i] === "0") {
7-
counter++;
8-
} else {
9-
if (counter > max) {
10-
max = counter;
11-
}
12-
counter = 0;
13-
}
14-
}
15-
console.log(N, max);
16-
return max;
2+
let max = 0;
3+
let counter = 0;
4+
const binary = N.toString(2);
5+
for (let i = 0; i < binary.length; i++) {
6+
if (binary[i] === "0") {
7+
counter++;
8+
} else {
9+
if (counter > max) {
10+
max = counter;
11+
}
12+
counter = 0;
13+
}
14+
}
15+
return max;
1716
}
1817

1918
module.exports = solution;

0 commit comments

Comments
 (0)