question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(FEL): redux use const for action types doesn't accept a valid answer

See original GitHub issue

Describe the Issue

As pointed out by @raditotev in the affected page, there is a valid solution, that isn’t accepted by the tests. But if we keep adding to the regex, it will be too complicated, and it will get out of hand for new contributor to be able to help.

Radi comment: https://github.com/freeCodeCamp/freeCodeCamp/pull/46753#issuecomment-1174857836

@lulululu12345 has mentioned a regex solution in his comment, but I am hoping there is an alternative to regex

Luke comment: https://github.com/freeCodeCamp/freeCodeCamp/pull/46753#issuecomment-1175136663

Here is the markdown page https://github.com/freeCodeCamp/freeCodeCamp/blob/04eaee51fc08b27576081519306819d467e62793/curriculum/challenges/english/03-front-end-development-libraries/redux/use-const-for-action-types.md

Affected Page

https://www.freecodecamp.org/learn/front-end-development-libraries/redux/use-const-for-action-types

Your code

const {LOGIN, LOGOUT} = {LOGIN: 'LOGIN', LOGOUT: 'LOGOUT'}

Expected behavior

This code is valid, so we should allow it to pass. But as mentioned before the regex is too complex, I wonder if we can do something that make the need for using regex unnecessary.

Screenshots

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ieahleencommented, Jul 9, 2022

there is a function to strip comments that can be used, so that the last two can be included

1reaction
raditotevcommented, Jul 9, 2022

There are two conditions to be fulfilled for this test:

  1. User should use variable instead of string
  2. Variable should be constant

Consider this:

assert(LOGIN === 'LOGIN' && LOGOUT === 'LOGOUT') // fulfils No. 1
assert(noWhiteSpace.includes('const')) // fulfils No.2
assert.isNotOk(noWhiteSpace.includes('let')) // No.2
assert.isNotOk(noWhiteSpace.includes('var')) // No.2

I think the above will work without being too implicit regarding the solution. I would say the last two assert.isNotOk could even be omitted because there is always a slim chance someone might write unconsciously some comment that might contain let or var as substrings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use const for Action Types - Redux - Free Code Camp
In this Redux tutorial we use const for action types. This video constitutes one part of many where I cover the FreeCodeCamp ...
Read more >
Redux - Use const for Action Types - The freeCodeCamp Forum
You have decleared const, use these const LOGIN and LOGOUT in authReducer() and action creators instead of strings.
Read more >
React-redux with Flow - action type name from imported ...
1 Answer 1 · 1) Add types to actions types in actionTypes.js . · 2) In the annotation to Action type in reducer...
Read more >
AOR 2013-11 - reply to Alaska Dispatch counsel comments
that a decision approving the use of campaign funds to pay for die appeal bond in the. Alaska litigation would be tantamount to...
Read more >
https://www.lingexp.uni-tuebingen.de/z2/Morphology...
1701 unruly c5 ax 5k 01483 umm re-issued momentary land-use dynamism 0.10 tendered ... 'true t.a. succulents sub-regions stingers starships siskins redux ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found