-
Notifications
You must be signed in to change notification settings - Fork 0
Permalink
Choose a base ref
{{ refName }}
default
Choose a head ref
{{ refName }}
default
Checking mergeability…
Don’t worry, you can still create the pull request.
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also or
learn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
Learn more about diff comparisons here.
base repository: mohajit2711/JavaScript-Alchemy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: Week1
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
...
head repository: mohajit2711/JavaScript-Alchemy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
- 5 commits
- 5 files changed
- 1 contributor
Commits on Dec 15, 2022
-
Given an array of numbers, sort the numbers ascending (1,2,3...) and return the sorted array. In fact, returning any negative value will have the same effect as returning -1 here. Any positive value will do the same as 1. This means we can shorten this function significantly: [3,2,4,1].sort(function comparison(a,b) { return a - b; }); Here, if a is less than b, the result of the subtraction will be negative (placing a first). If b is less than a the result will positive (placing b first).Configuration menu - View commit details
-
Copy full SHA for 83adcd2 - Browse repository at this point
Copy the full SHA 83adcd2View commit details -
Sorting Descending In the previous example, we sorted our array ascending: [3,2,4,1].sort(function comparison(a,b) { return a - b; }); A negative result moves a in front of b. A positive result moves b in front of a. Zero keeps the order unchanged. Sorting descending will be the opposite. We want a negative result to move b in front of a and a positive result to move a in front of b. Your Goal: Sort Numbers Descending Given an array of numbers sort them in descending order and return the array.Configuration menu - View commit details
-
Copy full SHA for bb251a6 - Browse repository at this point
Copy the full SHA bb251a6View commit details -
Comparing Strings Strings have a built-in method for convienent comparison called localeCompare. 'a'.localeCompare('a'); // 0 'a'.localeCompare('b'); // -1 "apple".localeCompare("abcd"); // 1 The localeCompare method also gives options for things like case, accent sensitivity and language. To learn more see the full documentation. Conveniently, localeCompare returns the numerical values we need to help sort our strings! As shown above, when a string is compared to one that would come after it, the result is -1. When compared to a string that should precede it, the result is 1. Your Goal: Sort Strings Ascending Given an array of strings, sort them in ascending order ('a','b','c'...) and return the sorted array. For debugging purposes, the tests will log your actual results versus the expected test results.Configuration menu - View commit details
-
Copy full SHA for 5f52bdf - Browse repository at this point
Copy the full SHA 5f52bdfView commit details
Commits on Dec 18, 2022
-
Comparing Strings Strings have a built-in method for convienent comparison called localeCompare. 'a'.localeCompare('a'); // 0 'a'.localeCompare('b'); // -1 "apple".localeCompare("abcd"); // 1 The localeCompare method also gives options for things like case, accent sensitivity and language. To learn more see the full documentation. Conveniently, localeCompare returns the numerical values we need to help sort our strings! As shown above, when a string is compared to one that would come after it, the result is -1. When compared to a string that should precede it, the result is 1. Your Goal: Sort Strings Ascending Given an array of strings, sort them in ascending order ('a','b','c'...) and return the sorted array. For debugging purposes, the tests will log your actual results versus the expected test results.Configuration menu - View commit details
-
Copy full SHA for 8dc79c7 - Browse repository at this point
Copy the full SHA 8dc79c7View commit details
Commits on Dec 19, 2022
-
Sorting by Multiple Properties When it comes to objects, we can sort by their properties. Let's consider some students: const students = [ { id: 1, graduated: true, grade: 86 }, { id: 2, graduated: false, grade: 96 }, { id: 3, graduated: false, grade: 78 }, { id: 4, graduated: true, grade: 96 }, ]; Let's sort this list by two rules in the following priority: Students who Graduated Highest Grades const students = [ { id: 4, graduated: true, grade: 96 }, { id: 1, graduated: true, grade: 86 }, { id: 2, graduated: false, grade: 96 }, { id: 3, graduated: false, grade: 78 }, ]; Now the list shows the graduated students at the top and then it sorts those groups by the highest grades. To compare students, this can be broken up into three scenarios. Your Goal: Sort Students Given an array of students, sort first by graduated then by grade like in the example above. Each object in the students array will have properties id, graduated and grade just like in the example shown above. For debugging purposes, the tests will log your actual results versus the expected test results.Configuration menu - View commit details
-
Copy full SHA for 39db3ce - Browse repository at this point
Copy the full SHA 39db3ceView commit details
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff Week1...main