fix(challenge): update Statistics Calculator: Step 27#53196
fix(challenge): update Statistics Calculator: Step 27#53196naomi-lgbt merged 61 commits intofreeCodeCamp:mainfrom
Conversation
|
👀 Review this PR in a CodeSee Review Map |
There was a problem hiding this comment.
As I am running this locally, and we will need to break this down further then I originally thought.
Here should be the correct flow for the first few steps.
Update Step 27
This step should focus on returning the array because we need a value to return if we are going to later call the getMode function and test it out.
updated description for step 27
To better understand how the `getMode` function is going to work, you will need to print out its contents. This will allow you to see what is happening as you build out the function. But first you will need to return the `array` so it can be tested properly.
Inside your `calculate` function return your `array` parameter.Correct starting code for updated Step 27
const getMode = (array) => {
const counts = {};
--fcc-editable-region--
--fcc-editable-region--
}new Step 28
This step will be where you will need to call the getMode function and pass in numbers and log it to the console.
updated description for new step 28
# --description--
Inside the `calculate` function, you have already called the `getMean` and `getMedian` functions.
Below those function calls, add a ` console.log(getMode(numbers))`.updated starting code for new step 28
const calculate = () => {
const value = document.querySelector("#numbers").value;
const array = value.split(/,\s*/g);
const numbers = array.map(el => Number(el)).filter(el => !isNaN(el));
const mean = getMean(numbers);
const median = getMedian(numbers);
--fcc-editable-region--
--fcc-editable-region--
document.querySelector("#mean").textContent = mean;
document.querySelector("#median").textContent = median;
}new step 29
This step should be about seeing the results in the console
updated description for new step 29
# --description--
To test out your `getMode` function so far, call the `calculate` function.
Then in your application, input the numbers `4`, `4`, `2`, `5` and click on the `Calculate` button.
Open up the console and you should see the array of numbers.updated starting code for new step 29
const calculate = () => {
const value = document.querySelector("#numbers").value;
const array = value.split(/,\s*/g);
const numbers = array.map(el => Number(el)).filter(el => !isNaN(el));
const mean = getMean(numbers);
const median = getMedian(numbers);
document.querySelector("#mean").textContent = mean;
document.querySelector("#median").textContent = median;
}
--fcc-editable-region--
--fcc-editable-region--Hope that hopes
|
@jdwilkin4 |
|
Hey @weilirs ! As I was testing it locally, I noticed that the
I pushed an update to your branch to resolve that. So you will need to pull down those new changes. But also, while I was testing it I noticed a typo in my original instructions here
If you look at the The latest commit I pushed up resolves that and updates the starting seed code. But also, while you are adding the steps, make sure you are running this frequently to make sure that the directions, seed code and tests all work and make sense in the context of the changes that you want to make. Also, it is perfectly fine to push back on review suggestions if you notice an error while testing it out. Maintainers are always open to that feedback and happy to discuss new approaches because at the end of the day we all have the same goal. As long as the issue is fixed, it is totally fine if it is a different approach then what was originally listed on the issue. As long as we get to a good resolution, that is fine. 👍 |
|
For the new step 29, what tests are needed since the user just types stuff into the input box and clicks a button. |
|
Based on the new description here for step 29, it looks like they still need to make a function call
The tests should be for the function call |
|
After looking at the code, it looks like the calculate function is already called in the HTML in the form element. so step 28 can include the console statement. But even with that change, and testing it out with numbers, I see the array of numbers and the null message. I replicated the project locally and on codesandbox and was not able to replicate the null error Maybe there is something in this particular testing environment that is causing this error. 🤔 @naomi-lgbt Do you have any thoughts on how to resolve this issue? |
|
Hey @weilirs ! It looks like changes were merged into main. That should resolve the issue you were running to earlier. |
|
|
You don't need to call the calculate function in step 29. Remember that I had said this earlier last week.
So you don't need to call it again in step 29. Step 29 can just continue with building out that forEach. I pulled down your branch and noticed that the changes in your Looking at your branch history on GitHub it doesn't look like that update is in there.
Double check that your branch is up to date and double check the frame.ts file to make sure it has the correct changes made from this PR here When I apply those changes locally and run step 28, the error goes away. Hope that helps 👍 |
|
please take a look at the new step 29. |
...learn-advanced-array-methods-by-building-a-statistics-calculator/65c4dc57418fd6bfc710d61d.md
Outdated
Show resolved
Hide resolved
...learn-advanced-array-methods-by-building-a-statistics-calculator/65c4dc57418fd6bfc710d61d.md
Outdated
Show resolved
Hide resolved
|
The shorter version works for me. @weilirs please apply those changes to step 26 |
|
@jdwilkin4 I wonder if we can omit the starting paragraph. It is repeating what was said in Step 25 and we are taking up a lot of vertical space already. So maybe start it with
Maybe we can also put the example object on one line? |
Yeah, if it is already mentioned in the previous step then it is fine to omit it in step 26.
Yeah, that's fine 👍 @weilirs Could make those changes, please and thank you 💯 |
...learn-advanced-array-methods-by-building-a-statistics-calculator/65c4dc57418fd6bfc710d61d.md
Outdated
Show resolved
Hide resolved
...learn-advanced-array-methods-by-building-a-statistics-calculator/65ca2d0625aa3a3201067f70.md
Outdated
Show resolved
Hide resolved
...learn-advanced-array-methods-by-building-a-statistics-calculator/65e62efde0592ec4b4bb6a69.md
Outdated
Show resolved
Hide resolved
...learn-advanced-array-methods-by-building-a-statistics-calculator/65f83a7ca7047318e3ccff7c.md
Outdated
Show resolved
Hide resolved
…a-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/65c4dc57418fd6bfc710d61d.md Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
…a-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/65ca2d0625aa3a3201067f70.md Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
…a-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/65e62efde0592ec4b4bb6a69.md Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
…a-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/65f83a7ca7047318e3ccff7c.md Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
...learn-advanced-array-methods-by-building-a-statistics-calculator/65ca2d0625aa3a3201067f70.md
Outdated
Show resolved
Hide resolved
|
Also, just to be clear. The seed code does not assign It assigns At no point is Just goes to show the solution code isn't the most readable. |
|
I do have a little nitpick with step 29 Chaining forEach onto the returned array:
It isn't a huge issue but I would prefer if the code asked for to be written was the same as the seed code in the next step. and not Maybe this instead? Inside your `getMode` function, on the empty line above your return call `forEach` on `array`. Your `.forEach()` method should have an empty callback function that takes an `el` parameter.
In the next few steps, you will use this loop to count the frequency of occurrences of each number in the array. |
|
Hey @weilirs ! It looks like you one outstanding comment here If you could resolve that, then this should be good to go Thanks 👍 |
I applied the changes. |
lasjorg
left a comment
There was a problem hiding this comment.
LGTM.
It was a bit of work, but I think this part of the challenge is in a much better place because of it. So thank you for your contribution.
naomi-lgbt
left a comment
There was a problem hiding this comment.
Why are we having them log it a second time? This seems like a great opportunity to reinforce the behaviour of function return values.
...learn-advanced-array-methods-by-building-a-statistics-calculator/65ca2d0625aa3a3201067f70.md
Outdated
Show resolved
Hide resolved
...learn-advanced-array-methods-by-building-a-statistics-calculator/65ca2d0625aa3a3201067f70.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Naomi <nhcarrigan@gmail.com>
…53196) Co-authored-by: jdwilkin4 <jwilkin4@hotmail.com> Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com> Co-authored-by: Naomi <nhcarrigan@gmail.com>
…53196) Co-authored-by: jdwilkin4 <jwilkin4@hotmail.com> Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com> Co-authored-by: Naomi <nhcarrigan@gmail.com>







Checklist:
mainbranch of freeCodeCamp.Closes #52753