-
Notifications
You must be signed in to change notification settings - Fork 194
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
base: master
Are you sure you want to change the base?
Conversation
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.
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) |
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.
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+"!") |
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.
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 |
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.
@@ -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) |
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.
@@ -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) |
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.
space between parameters
? new Array(i + 1).fill(null) | ||
: el.toString().repeat(i + 1).split("") |
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.
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) => { |
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.
Please, replace filter method with slice one
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
@@ -304,15 +339,20 @@ function get3TopItems(arr) { | |||
* [ 1, '2' ] => 1 | |||
*/ | |||
function getPositivesCount(arr) { | |||
throw new Error('Not implemented'); | |||
return arr | |||
.filter((el, i) => { |
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.
unused argument i
throw new Error('Not implemented'); | ||
return arr | ||
.filter((el, i) => { | ||
if ((typeof el === "number") && (el > 0)) return true |
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.
just return ((typeof el === "number") && (el > 0))
Please, see https://javascript.info/logical-operators
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() |
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.
spaces around operators
Please, avoid this code style, if-else is more readable than multiple conditional operators ? :
https://travis-ci.com/github/AlexGit2012/js-assignments