Skip to content

Commit 9c95507

Browse files
committed
71
1 parent e31d68d commit 9c95507

File tree

2 files changed

+10
-1
lines changed
  • 05-javascript-a-ds-new/2-advanced-javascript/2d-learn-recursion-by-building-binary-converter

2 files changed

+10
-1
lines changed

05-javascript-a-ds-new/2-advanced-javascript/2d-learn-recursion-by-building-binary-converter/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,13 @@
421421
result.textContent = decimalToBinary(parseInt(numberInput.value))
422422
numberInput.value = ''
423423
}
424+
```
425+
426+
### 🕷️ Fixing Bug 2 🕷️
427+
* The app works! But no result shows if input is 0!
428+
* I fix this by fixing my base case and setting the result to "0":
429+
```js
430+
if (input === 0) {
431+
return "0";
432+
}
424433
```

05-javascript-a-ds-new/2-advanced-javascript/2d-learn-recursion-by-building-binary-converter/code/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const result = document.getElementById("result")
44

55
const decimalToBinary = (input) => {
66
if (input === 0) {
7-
return "";
7+
return "0";
88
} else {
99
return decimalToBinary(Math.floor(input / 2)) + (input % 2);
1010
}

0 commit comments

Comments
 (0)