-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
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
fix(curriculum): last test for step 1 RPS project to better check for final result #54815
fix(curriculum): last test for step 1 RPS project to better check for final result #54815
Conversation
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.
i approve the solution 👍
updating changes from main
I'm not sure if we should specifically have a regex test for that. If anything, I think it should test for valid random generation and not invalid. It seems fairly improbable that the Set wouldn't contain all three strings after calling the function 50 times. So how about we just check the Set contains what we expect it to? I guess we can also remove falsy values and check the length, but I'm not sure if there is any benefit to that over just checking for the expected strings. |
I am not sure I am understanding what you mean here. Your `getRandomComputerResult` function should return one of the options in the `options` array.
```js
assert.include(["Rock", "Paper", "Scissors"], getRandomComputerResult());
``` So wouldn't it be redundant to do another |
That test checks that calling the function one time produces at least one of the 3 strings in the array. The other test calls it 50 times to "guaranty" the function produces each of the three strings at least one time. |
|
I had reached out to Naomi and went with her suggestion. |
That works, I wasn't really suggesting anything, just showing what I meant in code. But do we really need to loop that many times? I'm no statistician, but even with 50 loops the probability of Edit: I know it is quick on a desktop, but for low power devices it might be a little overkill. Just a thought. |
Yeah, that makes sense. |
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.
This looks good to me.
We could use 100 or even 200 for the loop, but I think 50 is just fine.
The last test for the Rock, Paper, Scissors game review project allows for incorrect answers like this to pass
this update should better test for the correct final result so hardcoded solutions like this don't pass
Checklist:
main
branch of freeCodeCamp.Closes #54814