- Notifications
You must be signed in to change notification settings - Fork179
Map and Set translation#148
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
b63e9f7
Map and Set translation
e739584
Update translation
37bcae9
Fix word
Regnised4c8d232
Update 1-js/05-data-types/07-map-set/article.md
Regnised915ffdb
Update 1-js/05-data-types/07-map-set/article.md
Regnised5585083
Update 1-js/05-data-types/07-map-set/article.md
Regnised44a0613
Update 1-js/05-data-types/07-map-set/article.md
Regnised7b2db38
Update 1-js/05-data-types/07-map-set/article.md
Regniseda03cc54
Update 1-js/05-data-types/07-map-set/article.md
Regnisedee5e346
Update 1-js/05-data-types/07-map-set/article.md
Regnised9d95f57
Map and Set: spaces and other fixes
Regnisedaa21873
Merge branch 'master' of github.com:Regnised/uk.javascript.info
Regnised1be3f05
Update 1-js/05-data-types/07-map-set/02-filter-anagrams/solution.md
tarasyyykFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions1-js/05-data-types/07-map-set/01-array-unique-map/_js.view/test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions1-js/05-data-types/07-map-set/01-array-unique-map/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions1-js/05-data-types/07-map-set/02-filter-anagrams/_js.view/test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions1-js/05-data-types/07-map-set/02-filter-anagrams/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Щоб знайти всі анаграми, давайте розіб'ємо кожне слово на літери і відсортуємо їх, а потім об'єднаємо масив знову в рядок. Після цього всі анаграми будуть однакові. | ||
Наприклад: | ||
tarasyyyk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
``` | ||
nap, pan -> anp | ||
@@ -9,14 +9,14 @@ cheaters, hectares, teachers -> aceehrst | ||
... | ||
``` | ||
Ми будемо використовувати відсортовані рядки як ключі в колекції Map, для того щоб зіставити кожному ключу тільки одне значення: | ||
```js run | ||
function aclean(arr) { | ||
let map = new Map(); | ||
for (let word of arr) { | ||
//розділіть слово на літери, відсортуйте їх та знову з'єднайте | ||
*!* | ||
let sorted = word.toLowerCase().split('').sort().join(''); // (*) | ||
*/!* | ||
@@ -31,9 +31,9 @@ let arr = ["nap", "teachers", "cheaters", "PAN", "ear", "era", "hectares"]; | ||
alert( aclean(arr) ); | ||
``` | ||
Сортування літер здійснюється ланцюжком викликів одним рядком `(*)`. | ||
Для зручності давайте розіб'ємо на декілька рядків: | ||
```js | ||
let sorted = word // PAN | ||
@@ -43,21 +43,21 @@ let sorted = word // PAN | ||
.join(''); // anp | ||
``` | ||
Два різних слова `'PAN'`і `'nap'`приймають ту ж саму форму після сортування букв - `'anp'`. | ||
Наступна лінія поміщає слово в об'єкт `Map`: | ||
```js | ||
map.set(sorted, word); | ||
``` | ||
Якщо ми коли-небудь ще зустрінемо слово в тій же відсортованої формі, тоді це слово перезапише значення з тим же ключем в об'єкті. Таким чином, декільком словами у нас буде завжди відповідати одна відсортована форма. | ||
Врешті-решт`Array.from(map.values())`приймає значення об'єкта-ітератора 'Map' (в цьому випадку нам не потрібні ключі) і повертає їх у вигляді масиву. | ||
Тут ми також можемо використовувати звичайний об'єкт замість`Map`,тому що ключі - це рядки. | ||
Ось один з варіантів рішень задачі: | ||
```js run demo | ||
function aclean(arr) { | ||
12 changes: 6 additions & 6 deletions1-js/05-data-types/07-map-set/02-filter-anagrams/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions1-js/05-data-types/07-map-set/03-iterable-keys/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions1-js/05-data-types/07-map-set/03-iterable-keys/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.