New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add decimal to binary converter project #50438
base: main
Are you sure you want to change the base?
feat: add decimal to binary converter project #50438
Conversation
👀 Review this PR in a CodeSee Review Map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Kris,
Saw this was reverted back to draft, but thought I'd provide early feedback on the instruction copy.
|
||
# --description-- | ||
|
||
<dfn>Recursion</dfn> is when a function calls itself. A good understanding of what recursion is an when to use it can make solving some problems much easier. For this project, you'll build a decimal to binary converter and use recursion to perform the calculations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to define recursion before we teach it?
|
||
# --description-- | ||
|
||
Use the `.getElementById()` method to get the button element with the id `convert` and store it in a variable called `convertBtn`. Then use the same method to get the `h2` element with the id `result` and store it in a variable called `result`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we combine this with the previous step? Campers should be pretty comfortable with selecting a bunch of elements by now.
|
||
Remove the `console.log()` statement from the callback function and add an `if` statement that checks if `e.key` is equal to the string `Enter`. Leave the body of your `if` statement empty for now. | ||
|
||
Note: Since the `Enter` and `Return` keys have similar functions, they both have the same value of `"Enter"`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Since the `Enter` and `Return` keys have similar functions, they both have the same value of `"Enter"`. | |
Note: Since the `Enter` and `Return` keys have similar functions, they both have the same string value of `Enter`. |
|
||
The `keydown` event fires every time a user presses a key on their keyboard, and is a good way to add more interactivity to `input` elements. | ||
|
||
Chain `.addEventListener()` to `numberInput`. Pass the string `keydown` as the first parameter, and pass an empty callback function as the second parameter to `.addEventListener()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chain `.addEventListener()` to `numberInput`. Pass the string `keydown` as the first parameter, and pass an empty callback function as the second parameter to `.addEventListener()`. | |
Chain `.addEventListener()` to `numberInput`. The event listener should listen for `keydown` events and take an empty callback function. |
This is the seventh project where campers use event listeners - do we want to take a more vague but thought provoking wording?
|
||
Now that your `checkUserInput()` function is set up for testing, you can use an event listener to call the function when users click the `Convert` button. | ||
|
||
Chain the `.addEventListener()` method to `convertBtn`. Pass the string `click` as the first parameter, and pass a reference to the `checkUserInput` function as the second parameter to `.addEventListener()`. Remember that function references are not called with parentheses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as step 6 above.
|
||
# --description-- | ||
|
||
While asynchronous, or <dfn>async</dfn>, code can be difficult to understand at first, it has many advantages. One of the most important is that it allows you to write non-blocking code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async
is technically a reserved keyword in JavaScript. Do we want to define it as a term here? I worry that might get confusing.
|
||
# --description-- | ||
|
||
Next, use string interpolation (`${}`) to set the `id` attribute to the `inputVal` property of the current object, `obj`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next, use string interpolation (`${}`) to set the `id` attribute to the `inputVal` property of the current object, `obj`. | |
Next, use string interpolation to set the `id` attribute to the `inputVal` property of the current object, `obj`. |
This is the seventh project using template literals - shouldn't need an example.
|
||
# --description-- | ||
|
||
Add a `class` attribute set equal to `animation-frame`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a `class` attribute set equal to `animation-frame`. | |
Add a `class` attribute set to `animation-frame`. |
decimalToBinary(1) returns "1" (base case) and gives that value to the stack below. Then it pops off the stack. | ||
``` | ||
|
||
Note that, since the string itself contains double quotation marks, you will need to use single quotation marks for your string value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They could also use backticks or escape the quotes.
When testing this, probably best to look at the value of the object property:
assert.equal(animationData[2].msg, 'decimalToBinary(1) returns "1" (base case) and gives that value to the stack below. Then it pops off the stack');
|
||
# --description-- | ||
|
||
Next, you'll remove the paragraph elements from the `div#show-animation` element after the delays you specified earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next, you'll remove the paragraph elements from the `div#show-animation` element after the delays you specified earlier. | |
Next, you'll remove the paragraph elements from the `#show-animation` element after the delays you specified earlier. |
Awesome, thank you for your helpful feedback @naomi-lgbt. I'll address all of your review comments ASAP. |
Hey @scissorsneedfoodtoo, how's this going :) ? |
Checklist:
main
branch of freeCodeCamp.Closes #XXXXX
Edit:
Converted to draft to ensure this doesn't get merged before the tests are in.Will open this up for early feedback now that the tests are passing.