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

Add ES6 syntax to Challenge' solution #36367

Merged
merged 3 commits into from Jul 19, 2019
Merged

Add ES6 syntax to Challenge' solution #36367

merged 3 commits into from Jul 19, 2019

Conversation

xJuggl3r
Copy link
Contributor

@xJuggl3r xJuggl3r commented Jul 3, 2019

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the master branch of freeCodeCamp.
  • None of my changes are plagiarized from another source without proper attribution.
  • All the files I changed are in the same world language (for example: only English changes, or only Chinese changes, etc.)
  • My changes do not use shortened URLs or affiliate links.

Closes #XXXXX

Added ES6 syntax to challenge' solution.
ES6 syntax for Challenge' solution
An optional way to solve the challenge using ES6 arrow functions

If using ES6, the same can be rewritten as:

```javascript
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```javascript
```js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thecodingaviator It is not necessary to use js. javascript should work with prism just fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed but since we're adding it to the other file, I figured why not do it here too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS works so I'm going to leave this.


In ES6 syntax we can make the function a bit less verbose:

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```js

@thecodingaviator thecodingaviator added status: waiting update To be applied to PR if a maintainer/reviewer has left a feedback and follow up is needed from OP language: English labels Jul 3, 2019
@RandellDawson
Copy link
Member

I see no reason to add an ES6 syntax version of the guide as there is no different algorithm being implemented here. It is strictly a syntax change of the same solution.

@xJuggl3r
Copy link
Contributor Author

xJuggl3r commented Jul 3, 2019

I agree there is no different algo, but on the other side, ES6 syntax should have some incentive, hence the suggestion.

@RandellDawson
Copy link
Member

RandellDawson commented Jul 3, 2019

Added solutions should have different logic and not just a change in syntax. In these specific challenges, you can not even use arrow function syntax through because of the need to use this so it is a mix of ES6 and conventional function syntax. It would be (maybe) different if you were replacing a for loop with the use of a higher order function like map or reduce, but that is not what is going on here.

If the consensus of other mods is your ES6 version is fine, I would rather see it replace the existing version instead of being a new addition. Otherwise it is just cluttering up the Guide.

@xJuggl3r
Copy link
Contributor Author

xJuggl3r commented Jul 3, 2019

Gotcha, thanks for the explanation.

@xJuggl3r xJuggl3r closed this Jul 3, 2019
@RandellDawson
Copy link
Member

RandellDawson commented Jul 3, 2019

Let's leave it open for some other mods to voice their opinions. See my last edited comment.

@RandellDawson RandellDawson reopened this Jul 3, 2019
@moT01
Copy link
Member

moT01 commented Jul 7, 2019

I'm not sure on these - Do we need more than one solution per challenges article? Part of the problem seems to be that we don't have a template to use for these articles. Some have a beginner/intermediate/advanced solution. Some just have one solution. Some have many annoying icons. There is very little consistency across the articles.

To be more specific on this PR - I don't care either way. The current articles are quite short and another solution doesn't clutter them up. But the added solutions are really just the same as the ones already there with a different syntax.

Yea, after looking closer - I think the best play here is to either not merge this or to replace the current solution with these new ones like @RandellDawson said.

So if you can replace the current solutions with your new ones @xJuggl3r - I think we could probably merge this - assuming the solutions work. And if you're going to do that - you could probably remove some of those curly brackets when using implicit returns like that as they are not needed.

@RandellDawson
Copy link
Member

RandellDawson commented Jul 19, 2019

@xJuggl3r Can you please implement @moT01's latest suggestions. Just replace the existing solutions with the changes mentioned.

Thank you.

Copy link
Contributor

@QuincyLarson QuincyLarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for these contributions, @xJuggl3r


If using ES6, the same can be rewritten as:

```javascript
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS works so I'm going to leave this.

@QuincyLarson QuincyLarson dismissed thecodingaviator’s stale review July 19, 2019 21:03

using js instead of JavaScript should be OK here - we don't want to be overly strict on things that don't impact the actual presentation.

@QuincyLarson QuincyLarson merged commit 58e7005 into freeCodeCamp:master Jul 19, 2019
six9 added a commit to six9/freeCodeCamp that referenced this pull request Jul 23, 2019
* Azuzunaga patch 1 (freeCodeCamp#21023)

* Add missing command and iTerm2 section

* Consolidate changes

* Update index.md (freeCodeCamp#36453)

* Added CSS logo (freeCodeCamp#24252)

* Fix command line guides in spanish (freeCodeCamp#24758)

* Add missing command and iTerm2 section

* Fix translation, grammar, actually translate a chunk

Also fix formatting and make text more conversational.

* Jump search Code in Java (freeCodeCamp#30962)

Code for Jump Search in Java.

* Added content to stub (freeCodeCamp#34325)

Added definitions and examples

* BFS in Java (freeCodeCamp#35027)

Code for implementation of Breadth-First-Search in Java.

* Added info; Fixed formatting; (freeCodeCamp#36329)

Added note on Scope
Fixed formatting of example and added better way to rewrite example.

* add informations about queries in graphql (freeCodeCamp#36428)

* Update index.md (freeCodeCamp#36349)

Removed some statements talking about the optimization potential of goto (which is mentioned but never specified), and I gave a possible use-case for goto followed by some constructs that can replace it, and ended on why goto is discouraged in C++

Added information about the memory behaviour of labels, the syntax to create a label, and where a label can actually be placed (within the same function).

* Update index.md (freeCodeCamp#36458)

* docs: replace Medium with fCC News (freeCodeCamp#36456)

* docs: replace Medium with fCC News (freeCodeCamp#36455)

* docs: replace Medium with fCC News (freeCodeCamp#36454)

* fix: Update docs, recommending install all packages (freeCodeCamp#36352)

* feat(client): add prev next btns to lessons (freeCodeCamp#35485)

* feat/add-prev-next-btns-to-lessons

redirect to learn instead of home

* fix/button-css-properties

* fix/change-buttons-to-suggested

* fix/add-tests+change-button-to-link

Co-authored-by: ojeytonwilliams ojeytonwilliams@gmail.com

* Revert "fix/add-tests+change-button-to-link"

This reverts commit ae26504.

* fix/add-tests+change-button-to-link

Co-authored-by: ojeytonwilliams <ojeytonwilliams@gmail.com>

* made semi-colon on basic-javascript challenge optional. (freeCodeCamp#36465)

* made closing operator optional.

* truncated unnecessary regex

* Minor edits for clarity. (freeCodeCamp#25841)

Edits for clarity and for grammar.

* Update a solution for "Find the Symmetric Difference" algorithm (freeCodeCamp#36379)

* Update advanced solution

* Replace HTML links with markdown syntax

* Remove obsolete sort()

* Use spread operator instead of Array.from

* fix: Init test output on backend challenges

Makes sure the test output console is initialized on backend as well as
classic challenges.  Previously it was tied to SidePanel which was not
always present.

* fix: Refactor challenge mounting and updating

componentDidMount and componentDidUpdate share a lot of code. This just
DRYs them out.

* fix: Remove non-functional css

* feat: Lint curriculum, including test yaml

* fix: Only lint staged files on commit

* fix: Add tests for the linter

* feat: Add scripts to format and lint with prettier

* feat: Add rule checking Prism languages

The linter now checks that fences have languages and that those languages are
supported by PrismJS. The linter has been extended over the guide with its own
set of rules that only validate code fences.

* fix(tools): Restrict prettier to css

* fix(tools): Relax rules for the guide

* fix(tools): Correct broken test

* fix(curriculum): added extra line before </section> tag - Engl… (freeCodeCamp#36278)

* fix(curriculum): format challenge markdown as per linting rules (freeCodeCamp#36326)

* fix: Format challenge markdown according to linting rules

* fix: Put spaces after section tags

* fix: remove guide linting and fix failing challenges

* fix: prettify css

* update translation bubble-sort (freeCodeCamp#36459)

* update translation bubble-sort

add examples code

* update: two-space indentation for all code

* Outputing an "auto" variable (freeCodeCamp#31263)

* fix: sent to local repo in error (freeCodeCamp#31165)

* Create index.md

This file introduces flex-grow: with screen shots and code samples. As with all of my commits, this is a proper contribution effort, neither copy & paste nor a links list.

* Update index.md

Added title: 'Flex Grow' to avoid Travis CL no frontmatter error.

* Update index.md

Added labels to the code blocks.

* fix: updated individual code items & sentences

Added <code></code> tags to individual code items.
Sorry for so many commits. I just saw the styling guide.

* Create flexbox-display-flex.md (freeCodeCamp#2)

* Create flexbox-display-flex.md

This file introduces the concept of display:flex and flex-direction:[row | column].

* Rename guide/english/css/flexbox-display-flex.md to guide/english/css/flexbox-display-flex/index.md

Changed the folder structure to comply with index.md.

* Update index.md

Added title: Display Flex to avoid Travice CL no frontmatter error.

* Update index.md

Added labels to the code blocks.

* fix: update individual code items.

Added <code></code> tags to individual code items.
Sorry for so many commits. I just saw the styling guide.

* Create index.md (freeCodeCamp#4)

* Create index.md

This file contains details about flex-basis, with screenshots and code samples. As with all of my commits, this is my own work not copy & paste or a lazy linkathon.

* Update index.md

Added the title; Flex Basis, to avoid Travis CI no frontmatter error.

* Update index.md

Added labels to the code blocks.

* fix: added labels for code items

Added <code></code> labels to individual code items.
Sorry for all of the commits. I just saw the styling guide. Doing my own QC.

* Added the nltk library installation. (freeCodeCamp#31603)

* Added the nltk library installation.

* Address feedback

* Add ES6 syntax to Challenge' solution (freeCodeCamp#36367)

* ES6 syntax

Added ES6 syntax to challenge' solution.

* Add ES6 solution to challenge

An optional way to solve the challenge using ES6 arrow functions

* content(guide): add blockchain-development article (freeCodeCamp#36256)

* Create index.md

* Update index.md

* Update index.md

* Update index.md

* Update index.md

* added small entry for docker exec (freeCodeCamp#33989)

there's so much missing here (qwq)

* order point included (freeCodeCamp#33548)

* Add list article (freeCodeCamp#35018)

* feat(guide): added java implementation to quicksort (freeCodeCamp#36005)

* feat: added java implementation to quicksort

* fix: edited heading in quicksort

* feat: added java implementation for red-black trees (freeCodeCamp#36026)

* feat: Add guide article and update its challenge (freeCodeCamp#36371)

* feat: Add guide article and update its challenge

* Update guide/english/certifications/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion/index.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update guide/english/certifications/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion/index.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update guide/english/certifications/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion/index.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update guide/english/certifications/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion/index.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: Stop hints from being hidden

* fix: Improve the wording.

* Update index.md

Fixed per suggestion

* Update index.md

Fixed per suggestion

* feat: Add article for Elixir Keyword Lists (freeCodeCamp#36141)

* Really elaborating on the network topic to be nearly all inclusive (freeCodeCamp#36140)

This might be better put in a topic separate from C, its own topic, since the network socket interface is accessible in Java, C#, Python, PHP, NodeJS, etc. . Since the socket api is written in C itself, the system calls, and most languages will use these same C system calls, I think it still works to offer the main explanation in C, then either have an example server and client in every language PHP, Ruby, Java, C#, Obj-C, etc

* Support Vector Machine index updated. (freeCodeCamp#33509)

Added multiple sections in the index page of support vector machine.

* Added the topic Evaluating the clustering (freeCodeCamp#35855)

* Added the topic Evaluating the clustering 

How can we evaluate the clustering algorithms,  based on analyzing our results.

* Fixed grammar and put in second person

* Add notes on when Erlang began and became Open Source. (freeCodeCamp#33270)

* Update index.md (freeCodeCamp#33013)

* add functional-language/index.md (freeCodeCamp#33258)

A summary of the functional programming features of Erlang and the consequences.

* add pure-functions/index.md (freeCodeCamp#32887)

A description of the important of pure functions and their limitations in Erlang

* added details for crossfilter.js (freeCodeCamp#32677)

Added brief details and setup instructions for crossfilter.js

* add shell/index.md (freeCodeCamp#32378)

Description of the Erlang shell and how to use it as a simple interpreter.

* add names/index.md (freeCodeCamp#32398)

Notes on names that begin with an upper case letter and those that don't and naming conventions.

* Update index.md (freeCodeCamp#32348)

Added details to description of NP completeness.

* Added optimization algorithms for Gradient Descent (freeCodeCamp#32096)

* Contribution on the topic. (freeCodeCamp#31767)

* Contribution on the topic.

Added some basic information on the concept of Multi Layer Perceptron. Added an image for better understanding of the concept.

* Added extra information.

Check out the following piece of data on MLP.

* Update index.md

* Update index.md

* Grammatical changes (freeCodeCamp#32856)

i changes two verbs that maybe were too unsuitable to code.

* Added install instructions for Arch Linux (freeCodeCamp#30830)

* Added new section (freeCodeCamp#28311)

Added new section about getting the message inside an exception

* Add Section on Docker CE for Linux and Install guide in index.md (freeCodeCamp#27351)

* Create index.md

Installation and Setup guide for Docker CE on Linux.

* Rename guide/english/linux/install-and-Setup-DockerCE-in-linux/index.md to guide/english/linux/install-and-setup-dockerce-in-linux/index.md

* add `map` function to haskell section (freeCodeCamp#25718)

Add `map` function to haskell section of guide.freecodecamp.org

* Updated Data-Drive Design content (freeCodeCamp#33449)

* Updated Data-Drive Design content

Added detailed introduction to Data Driven Design. What, Why, and How of the subject and also added tools and resources for the same.

* Update index.md

* Fix typos

* fix(docs): minor SPG changes

* fix(mathjax): prevent load in offline mode

* chore(root): update dependencies to latest

* fix: rename challenge md parser to correct casing

* fix: create lockfiles for audits

* fix(parser): bump version and publish

* chore(client): resolve linting errors in client

* fix: use rounding to fix floating point comparison

* chore(client): update dependencies except gatsby

* fix(client): apply type errors from code review

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Add solution to hint stub (mongoDB model.findById) (freeCodeCamp#36494)

* Add solution to hint stub (mongoDB model.findById)

* Use callback in `createAndSavePerson()`

* Replace stub for mongDB lesson (use model.findOne) (freeCodeCamp#36493)

* Replace stub for mongDB lesson (use model.findOne)

Add solution

* Use callback in `createAndSavePerson()`

* Replace stub for mongoDB lesson (use model.find) (freeCodeCamp#36491)

* Replace stub for mongoDB lesson

* Replace stub for "Use model.find to search your database"
* Include hints
* Include solution

* Use callback in `createAndSavePerson()`

* fix: corrected hints syntax

* Replace stub for mongoDB lesson (create many records) (freeCodeCamp#36492)

* Replace stub with hints and solution

For "create many records" mongoDB lesson

* Fix markdown for inline code

Add new line to allow markdown to render inline code

* Use callback in `createAndSavePerson` function

* fix: corrected hints syntax

* Replace stub with hints and code solution (freeCodeCamp#36487)

* Replace stub with hints and code solution

* Change spoiler tag text

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update `createAndSavePerson` to use callback

Previous solution had an empty callback

* fix: added hint header

* Add hints for "install and set up mongoose" (freeCodeCamp#36474)

* Add hints for "install and set up mongoose"

* Add hint for how to solve the timeout error

* Add hint for what to put in the `.env` file

* Add code snippets for `.env`, `package.json` and `myApp.js`

* Restructure hints and headers

* Remove code solution from timeout hint

* Restructure headers to match the new hint template

* Move hint subject below the header

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Move hint subject below the header

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update text in spoiler tag

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update text in spoiler tag

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update text in spoiler tag

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Add javascript tag to code block

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Move first line of code below ```

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Remove placeholder text

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Add json tag to code block

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Remove redundant sentence

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Format solutions section and hint

* Replace tabs with 2 space indents in `package.json`
* Remove the spoiler tags from each file name
* Remove placeholder comments in `myApp.js` to make it easier to read the code
* Update sentence in hint as two words were not displaying

* fix(docs): npm run commit has been removed (freeCodeCamp#36451)

* fix(docs): npm run commit has been removed

* fix(docs): using `npm ci` makes more sense for bootstrapping

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting update To be applied to PR if a maintainer/reviewer has left a feedback and follow up is needed from OP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants