in .reduce((a,c)=> ... ? c : a) the a is our current best choice. The c is the next one we are checking. We make a comparison (in ...) and if c is a better choice, we return that, otherwise we return a. Whichever one we return, will become a in the next comparison. When there is nothing left to compare, a is returned (the best choice from all).
have question about comparison in reduce:
if it's false then method takes next object in 'c', but 'a' is still first object?
and if it's true then method takes 'c' in 'a' and next object to 'c'?
There is no tests for several whitespaces between each word, and almost everyone uses .trim(). But it says in description ("while ensuring there is exactly one space between each word").
this sollution doesn't pass tests now becouse of this reason
now he has deleted his account
got it. thank you very much!
in
.reduce((a,c)=> ... ? c : a)
thea
is our current best choice. Thec
is the next one we are checking. We make a comparison (in...
) and ifc
is a better choice, we return that, otherwise we returna
. Whichever one we return, will becomea
in the next comparison. When there is nothing left to compare,a
is returned (the best choice from all).have question about comparison in reduce:
if it's false then method takes next object in 'c', but 'a' is still first object?
and if it's true then method takes 'c' in 'a' and next object to 'c'?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in
If
v in seen
thenfalse
and that means, filter thev
from the array.how does "v in seen" works? is it just check of property in object? and if it's false then u add char to object and a filter return this char too?
JavaScript
When reporting a problem, please state the language you're talking about, not all languages have the same tests.
There is no tests for several whitespaces between each word, and almost everyone uses .trim(). But it says in description ("while ensuring there is exactly one space between each word").
u need 'baab' from the example "zzbaabcd", then it's 4
This comment is hidden because it contains spoiler information about the solution