-
Notifications
You must be signed in to change notification settings - Fork 1
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
задача 3.1 не доделана, не проходит 1 тест. задачи 3.2-3.3 выполнены #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,9 @@ | |
* @returns {object | undefined} - returns new object or undefined if nothing did't pass | ||
*/ | ||
export function invertObj(obj) { | ||
if (obj === undefined) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return; | ||
|
||
const arr = Object.entries(obj); | ||
return Object.fromEntries(arr.map(([keys,values])=>[values,keys])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. опечатка? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,20 @@ | |
* @returns {string} - the new string without extra symbols according passed size | ||
*/ | ||
export function trimSymbols(string, size) { | ||
if (string==='' || size === 0) return ''; | ||
if (size === undefined) return string; | ||
|
||
let newStr = ''; | ||
let n = 1; | ||
for (let i = 0; i < string.length; i++) { | ||
if (string[i] === string[i-1]) { | ||
n++; | ||
} | ||
else n = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. лучше не опускать скобки в if/else для повышения читаемости |
||
|
||
if (n <= size) { | ||
newStr = newStr + string[i]; | ||
} | ||
} | ||
return newStr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему проверка идет только для первого элемента? Кажется что это условие можно опустить, у вас ниже похожая работа но в reduce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Попробуйте избавиться от этой строки