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

#1-4 Tasks. Alexey_Karavaychik #824

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

AlexGit2012
Copy link

Copy link
Collaborator

@vramaniuk vramaniuk left a comment

Choose a reason for hiding this comment

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

Please, try to follow these rules https://javascript.info/coding-style

I'll mark the PR as "Draft", please click "ready for review" when it will be finished. Thank you!

@@ -22,7 +22,7 @@
* '', 'bb' => 'bb'
*/
function concatenateStrings(value1, value2) {
throw new Error('Not implemented');
return (value1+value2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

spaces around operators

Please, try to follow these rules https://javascript.info/coding-style

@@ -55,7 +55,7 @@ function getStringLength(value) {
* 'Chuck','Norris' => 'Hello, Chuck Norris!'
*/
function getStringFromTemplate(firstName, lastName) {
throw new Error('Not implemented');
return ("Hello, "+firstName+" "+lastName+"!")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines +102 to +108
while (value[0] === (" ") || value[0] === ("\t")) {
value = (value[0] === (" ") || value[0] === ("\t") ? value.substring(1) : value)
}
while (value[value.length-1] === (" ") || value[value.length-1] === ("\t")) {
value = (value[value.length-1] === (" ") || value[value.length-1] === ("\t") ? value.substring(0,value.length-1) : value)
}
return value
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -130,7 +136,8 @@ function repeatString(value, count) {
* 'ABABAB','BA' => 'ABAB'
*/
function removeFirstOccurrences(str, value) {
throw new Error('Not implemented');
let pos = str.indexOf(value)
return str.substring(0,pos)+str.substring(pos+value.length,str.length)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -145,7 +152,7 @@ function removeFirstOccurrences(str, value) {
* '<a>' => 'a'
*/
function unbracketTag(str) {
throw new Error('Not implemented');
return str.substring(1,str.length-1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

space between parameters

Comment on lines +301 to +302
? new Array(i + 1).fill(null)
: el.toString().repeat(i + 1).split("")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, avoid this code style, if-else is more readable than multiple conditional operators ? :

@@ -286,16 +319,18 @@ function propagateItemsByPositionIndex(arr) {
* [ 10, 10, 10, 10 ] => [ 10, 10, 10 ]
*/
function get3TopItems(arr) {
throw new Error('Not implemented');
return arr.sort((a, b) => a - b).reverse().filter((el, i) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -304,15 +339,20 @@ function get3TopItems(arr) {
* [ 1, '2' ] => 1
*/
function getPositivesCount(arr) {
throw new Error('Not implemented');
return arr
.filter((el, i) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

unused argument i

throw new Error('Not implemented');
return arr
.filter((el, i) => {
if ((typeof el === "number") && (el > 0)) return true
Copy link
Collaborator

Choose a reason for hiding this comment

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

just return ((typeof el === "number") && (el > 0))

Please, see https://javascript.info/logical-operators

Comment on lines +639 to +647
let headArr = arr.filter((el,i)=>{
if (i<Math.floor(arr.length/2)) return true
})
let tailArr = arr.filter((el,i)=>{
if (i>=Math.ceil(arr.length/2)) return true
})
let middle = arr.length%2===0 ? [] : [arr[Math.floor(arr.length/2)]]

return arr.length===2 ? [arr[1],arr[0]] : [tailArr.concat(middle.concat(headArr))].flat()
Copy link
Collaborator

Choose a reason for hiding this comment

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

spaces around operators

Please, avoid this code style, if-else is more readable than multiple conditional operators ? :

@vramaniuk vramaniuk marked this pull request as draft August 27, 2020 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants