Skip to content
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

Update step 74 of spreadsheet project #54327

Closed
ThornDuke opened this issue Apr 8, 2024 · 6 comments · Fixed by #54417
Closed

Update step 74 of spreadsheet project #54327

ThornDuke opened this issue Apr 8, 2024 · 6 comments · Fixed by #54417
Labels
new javascript course These are for issues dealing with the new JS curriculum scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. status: PR in works Work in Progress (WIP) Issues. type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc.

Comments

@ThornDuke
Copy link

Describe the Issue

My solution meets all the challenge requests, but is rejected with incomprehensible exceptions.

Affected Page

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-functional-programming-by-building-a-spreadsheet/step-74

Your code

const highPrecedence = str => {
  const regex = /^(\d*\.?\d+)\s*([\*\/])\s*(\d*\.?\d+)$/;
}

Expected behavior

My solution should pass the challenge.

Screenshots

No response

System

  • Device: Laptop
  • OS: MacOs Ventura
  • Browser: Chrome
  • Version: 123.0.6312.107

Additional context

Here (https://forum.freecodecamp.org/t/learn-functional-programming-by-building-a-spreadsheet-step-74/684317/3?u=sergio.am.spina) the correctness of my solution was recognized (and perhaps the incorrectness of the official solution), and here (https://forum.freecodecamp.org/t/learn-functional-programming-by-building-a-spreadsheet-step-74/684317/5?u=sergio.am.spina) it was suggested to me to open an issue.

@ThornDuke ThornDuke added scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix. type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc. labels Apr 8, 2024
@jdwilkin4
Copy link
Contributor

jdwilkin4 commented Apr 9, 2024

Hi @ThornDuke !

Thank you for reporting this issue.

After looking at the challenge and corresponding tests, it looks like the challenge could be restructured this way:

const highPrecedence = str => {
  const regex = "regex goes here"
  return regex.test(str); // have them return the test of the regex against the str
}

this should remove most of the regex tests and just test the final outcome.
This should also allow for a variety of correct answers that meet the problem statement.
Then the next step could be to remove the return regex.test(str) since that is basically just for testing purposes.

I will open this up for discussion to see what the rest of the team thinks

@jdwilkin4 jdwilkin4 added status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. new javascript course These are for issues dealing with the new JS curriculum labels Apr 9, 2024
@ojeytonwilliams
Copy link
Contributor

Sounds good, @jdwilkin4. Any time we can test what the learners code does, instead of checking the syntax, I think we should.

@ThornDuke
Copy link
Author

I'm not part of the "rest of the team". But I add that this structure

const highPrecedence = str => {
  const regex = "regex goes here"
  return regex.test(str);
}
console.log(highPrecedence('some'string'))

(with the reservation of eliminating unnecessary lines once the tests are finished) it would be useful

  1. to teach how to develop a regex with the "try - test - try again" cycle
  2. to teach to have a continuous relationship with the console during development.

Just my two cents.

@jdwilkin4 jdwilkin4 added help wanted Open for all. You do not need permission to work on these. and removed status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix. labels Apr 11, 2024
@jdwilkin4
Copy link
Contributor

jdwilkin4 commented Apr 11, 2024

I have opened this up for help wanted.

Note to contributors

Changes to step 74

For step 74, we want campers to create the regex and then return regex.test(str);
You will need to update the step description and tests.

For the tests we should just focus on checking for the following:

  1. did they create a regex variable(Note: That test is already in there)
  2. did they assign a regular expression to their regex variable. (Note: That test is already in there)
  3. did they return regex.test(str);
  4. have a test to check if highPrecedence("5*3") is true. If they did the regex correctly, then the test should be true. Here are the chai assert methods

adding a new step 75

Read through the directions on how to add a new step here
https://contribute.freecodecamp.org/#/how-to-work-on-practice-projects?id=how-to-work-on-practice-projects

For the new step 75 directions, have them add this console.log(highPrecedence("5*3"));. Then add tests to make sure they added that console statement.

adding a new step 76

For the new step 76, the directions should be to remove the return regex.test(str); and the console.log(highPrecedence("5*3")); because that was just for testing purposes. Then add tests to make sure they did that.

@jdwilkin4 jdwilkin4 changed the title The system raises an error even for correct answers, and does not allow you to proceed to the next challenge Update step 74 of spreadsheet project Apr 11, 2024
@violet102-png
Copy link
Contributor

Taking a stab at this - will follow up if any question comes up!

@GloriaNOnwuneme
Copy link

Hi - I'm struggling with step 74 as well. I've tinkered with my regex based on your console prompts. With the following statement, the console no longer flags my first capture group:
const regex = /([.\d]+)([*|/])([.\d]+)/gi;

The freeCampCode console does, however, raise the following three issues:

Your second capture group should match a * or / operator. Use a character class in the capture group.
Your regex should use a third capture group.
Your third capture group should be the same as your first capture group.

...Leaving me with three questions about each of my capture groups.

1. The first capture group, although no longer flagged, allows for 1 or more decimal points, which is inappropriate. When I try to move the + operator like so, to specify that only digits are to be unlimited:
([.\d**+**])
The console flags the first capture group again.

2. Regarding my second capture group (i.e. ([*|/])): What's the rule on escaping special characters when they're in character classes? According to the MDN regex cheatsheet, the dot operator doesn't need to be escaped in a character class: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Cheatsheet#quantifiers

I've tried modifying this capture group as follows:
([*|/]) - don't specify that they're to be alternatives
([|/]) - don't escape multiplication sign
([*|/]) - don't escape division sign
([
|/]) - don't escape any signs
(*/) - don't use square brackets, but escape special characters (which the exercise seems to suggest means I'm not using a character class within the capture group). I also tried all of the above without square brackets.

NB: I also tried (*/) for the sake of it, but visual feedback told me this was a bad idea - everything written after the group was styled as variables would be on the freeCodeCamp interface.

The console message about the second capture did not change with any of the above modifications.

3. I'm not sure why the console is flagging my third capture group, given that it's exactly the same as the first one. It suggests to me that the console is not happy with group no. 2.

My work on this task is degenerating into guesswork - I'd be most grateful for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new javascript course These are for issues dealing with the new JS curriculum scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. status: PR in works Work in Progress (WIP) Issues. type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc.
Projects
None yet
5 participants