the reduce method takes a callback function, this callback function takes two main params too,
the first one is called accumulator or previous, this param detects what returned value of the function that called back and assign it to itself.
so here at first it puts 10 as value to "v" and then put that v in the function witch will evaluate it and lets say that it increases the value by one so the return value is now 11, now the value of v will be updated and become 11 and so on.
finally solved.
This comment is hidden because it contains spoiler information about the solution
i'm sorry but i can't see your reply cause i didn't solve the challenge,
could you tell me what's wrong with the solution
This comment is hidden because it contains spoiler information about the solution
i didn't get it at first it => goodVsEvil('1 1 1 1 1 1', '1 1 1 1 1 1 1'). i thought that good worth is
1+1+1+1+1+1= 6 means "Hobbits, Hobbits,....." so the good army contain six Hobbits, and evil army contain
seven Orcses so evil wins
this got me confused
the description should be better.
This comment is hidden because it contains spoiler information about the solution
the reduce method takes a callback function, this callback function takes two main params too,
the first one is called accumulator or previous, this param detects what returned value of the function that called back and assign it to itself.
so here at first it puts 10 as value to "v" and then put that v in the function witch will evaluate it and lets say that it increases the value by one so the return value is now 11, now the value of v will be updated and become 11 and so on.
enjoy
this is the smartest way, without built in methods