The right hand side of the || is only evaluated if the left hand side is zero (a falsy value). So the sorting prioritizes count (objects with higher count come first), and when both counts are equal, the next condition is used (alphabetical sorting, by src and then by char).
The code in the rightmost brackets gets executed first, converting the input string to uppercase.
Then, this value is passed into the leftmost pair of brackets (through the use of an es6 arrow function), and compared against the reversed string.
Well here Array is an object and Object.assign does what it's name tells us, it assigns or say inserts the given properties to the given object.
As here we are assigning those square, cube etc properties to the Array.prototype object.
Hope you get it?
else do let me know, I will give you some examples!
what is happening from (.concat, '.concat() wil..................)
and why and how are we getting ' '(space) for the second argument whereas it should return some value(like e) here?
Before starting I did one wonderful thing, that is, started reading comments because I knew this will be really really confusing one, and thank god I did, I got motivated and I didn't even got a little anger all thanks to the people who were encouraging to not to give up, and yeah finally I was able to solve it, but still for you help here's a HINT:
HINT:
Try to find the source code of the given function, in that you will find the (answer) or (instructions to pass) or (in simple secret to open that box)...
you can search how to ..... and you will for sure eventually get to the answer, don't forget to appreciate the creator of this wonderful kata!
var titanic = new Ship(15, 10);
Taking into account that an average crew member on board adds 1.5 units to the draft, a ship that has a draft of more than 20 without crew is considered worthy to loot. Any ship weighing that much must have a lot of booty!
Here 1.5 has no relation with the input values, such as 15(draft) and 10(crew) here, so It is kinda formula or a hardcoded value, which you have to use to find the real value of the crews and then removal of that value from total ships value(draft) gives you the required value, which can be used to determine whether to loot it or not?
what does - - do in that code
The right hand side of the
||
is only evaluated if the left hand side is zero (a falsy value). So the sorting prioritizescount
(objects with higher count come first), and when bothcount
s are equal, the next condition is used (alphabetical sorting, bysrc
and then bychar
).The code in the rightmost brackets gets executed first, converting the input string to uppercase.
Then, this value is passed into the leftmost pair of brackets (through the use of an es6 arrow function), and compared against the reversed string.
What is '.toUpperCase() doing here? ( I know what it does but why are we using it here?)
Please don't spoil solutions.
This comment is hidden because it contains spoiler information about the solution
can somebody explain me, what exactly happening or we doing in the sort after
||
or after the OR part?Well here
Array
is an object andObject.assign
does what it's name tells us, it assigns or say inserts the given properties to the given object.As here we are assigning those
square, cube etc
properties to theArray.prototype
object.Hope you get it?
else do let me know, I will give you some examples!
BTW CLEVER code!
This comment is hidden because it contains spoiler information about the solution
Thanks will try that :) , and are you still reading it or ?
and how is your progress now?
what is happening from (.concat, '.concat() wil..................)
and why and how are we getting ' '(space) for the second argument whereas it should return some value(like e) here?
why does this work?
how is this working?
Before starting I did one wonderful thing, that is, started reading comments because I knew this will be really really confusing one, and thank god I did, I got motivated and I didn't even got a little anger all thanks to the people who were encouraging to not to give up, and yeah finally I was able to solve it, but still for you help here's a HINT:
HINT:
Try to find the source code of the given function, in that you will find the (answer) or (instructions to pass) or (in simple secret to open that box)...
you can search how to ..... and you will for sure eventually get to the answer, don't forget to appreciate the creator of this wonderful kata!
Thanks for this Amazing kata BTW ;)
Here 1.5 has no relation with the input values, such as 15(draft) and 10(crew) here, so It is kinda formula or a hardcoded value, which you have to use to find the real value of the crews and then removal of that value from total ships value(draft) gives you the required value, which can be used to determine whether to loot it or not?
Loading more items...