You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sort an array alphabetically using the sort Method - need to specify the array should be returned from the function #43417
first timers onlyOpen for anyone doing contributions for first time. You do not need permission to work on these.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.
function alphabeticalOrder(arr) {
// Only change code below this line
arr.sort((a,b) => a === b ? 0 : a < b ? -1 : 1);
// Only change code above this line
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
Expected behavior
The instructions on this page say, "Use the sort method in the alphabeticalOrder function to sort the elements of arr in alphabetical order." Since sort happens in place, I didn't realize I need to return the value to pass the challenge, I kept thinking there was something wrong with my code. Maybe just adding a line "return arr;" in the template code would make this more clear, or updating the instructions to specify the array needs to be returned. Would be good to mention that sorting happens in place too, I only knew because I happened to look at the Mozilla documentation.
the tests say "should return", I'm not sure how much this would need to be changed, but yes, it would be more user friendly to make it more clear that the function should return the expected result
This looks something that can be fixed by "first time" code contributors to this repository. Here are the files that you should be looking at to work on a fix:
Please make sure you read our guidelines for contributing, we prioritize contributors following the instructions in our guides. Join us in our chat room or the forum if you need help contributing, our moderators will guide you through this.
Sometimes we may get more than one pull requests. We typically accept the most quality contribution followed by the one that is made first.
first timers onlyOpen for anyone doing contributions for first time. You do not need permission to work on these.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.
Activity
majestic-owl448 commentedon Sep 9, 2021
the tests say "should return", I'm not sure how much this would need to be changed, but yes, it would be more user friendly to make it more clear that the function should return the expected result
I don't know what would be the best way tho
gikf commentedon Sep 9, 2021
Maybe something like this, added to the instructions?
majestic-owl448 commentedon Sep 9, 2021
That would work, let's go with it!
Thanks for opening this issue.
This looks something that can be fixed by "first time" code contributors to this repository. Here are the files that you should be looking at to work on a fix:
List of files:
Please make sure you read our guidelines for contributing, we prioritize contributors following the instructions in our guides. Join us in our chat room or the forum if you need help contributing, our moderators will guide you through this.
Sometimes we may get more than one pull requests. We typically accept the most quality contribution followed by the one that is made first.
Happy contributing.
(fix)Sort an array alphabetically using the sort Method - Array is re…
(mod)Curriculum - Adding explicit instructions so that function will …
(fix)Curriculum - Correcting grammetic error in instructions freeCode…
mod: updated transaltion message freeCodeCamp#43417
abhinav-raman commentedon Sep 12, 2021
Is this issue fixed? I am a first-timer and interested in contributing to this issue.
majestic-owl448 commentedon Sep 12, 2021
@abhinav-raman there is already an open PR targeting this issue
fix: Curriculum - Updated grammatical error in instructions freeCodeC…
fix(curriculum): specify array is returned from the function (#43425)
Merge (#4)