-
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 Task. Roman Tarasenko #845
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.
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.
Please, try to follow these rules https://javascript.info/coding-style
spaces between operators
@@ -73,7 +76,7 @@ function getAverage(value1, value2) { | |||
* (-5,0) (10,-10) => 18.027756377319946 | |||
*/ | |||
function getDistanceBetweenPoints(x1, y1, x2, y2) { | |||
throw new Error('Not implemented'); | |||
return Math.sqrt(((x2-x1)*(x2-x1)) +((y2-y1)*(y2-y1))); |
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.
Try to improve using Math.hypot
@@ -160,7 +164,7 @@ function parseNumberFromString(value) { | |||
* 1,2,3 => 3.741657386773941 | |||
*/ | |||
function getParallelipidedDiagonal(a,b,c) { | |||
throw new Error('Not implemented'); | |||
return Math.sqrt((a*a + b*b) + c*c) |
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.
Try to improve using Math.hypot
@@ -23,7 +23,11 @@ | |||
* [0, 1, 2, 3, 4, 5], 5 => 5 | |||
*/ | |||
function findElement(arr, value) { | |||
throw new Error('Not implemented'); | |||
if (arr.find((el) => el === value)) { | |||
return arr.indexOf(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.
Just this line will work as a solution
let arrPos = []; | ||
arr.map((el)=>{ | ||
if(el > 0){ | ||
arrPos.push(el) | ||
} | ||
}); | ||
return arrPos; |
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, use Array.prototype.filter method here
function removeFalsyValues(arr){ | ||
let newArr = []; | ||
arr.map((el) =>{ | ||
if (Boolean(el) !== false){ |
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.
Redundant condition. Just if (el) {
will work
Please, see https://javascript.info/logical-operators
let newArr = arr.reverse(); | ||
if (arr.length > 3) { | ||
newArr.length = 3; | ||
} | ||
return newArr; |
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.
If test cases had unsorted array, it woudn't work.
To prevent errors in case tests will reworked, please add sort method in place of reverse
let newArr = []; | ||
if (arr.length){ | ||
arr.map((el) =>{ | ||
if (Boolean(el) === false){ |
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.
if (!el)
will work
Please, see https://javascript.info/logical-operators
let newArr = []; | ||
arr.map((el) =>{ | ||
let i = newArr.find(item => item === el); | ||
if (i === undefined){ |
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.
!newArr.includes(el)
will work. And remove line with find
And try to resolve conflicting files. It's very significant in real project |
https://travis-ci.org/github/RomanTarasenko/js-assignments/builds/714484766