tl;dr: what does => do?
I've just finished solving a problem on codewars and after looking at other peoples' common responses to the problem, I keep seeing this: =>
The problem is below:
You have a quiver of arrows, but some have been damaged. The quiver contains arrows with an optional range information (different types of targets are positioned at different ranges), so each item is an arrow. You need to verify that you have some good ones left, in order to prepare for battle. The below is an example array which is the quiver of arrows.
anyArrows([
{range: 5},
{range: 10, damaged: true},
{damaged: true}
])
If an arrow in the quiver does not have a damaged status, it means it's new.
This is an example I saw which returns true or false, depending on if there is an undamaged arrow in the quiver:
function anyArrows(arrows){
return arrows.some(a => !a.damaged);
}
Now, that was way shorter than my code! Mine was a lot more basic:
function anyArrows(arrows){
for ( var i = 0 ; i < arrows.length ; i++ ){
if ( arrows[i].damaged === false ) { return true; }
else if (arrows[i].damaged === true) { return false; }
else if (arrows[i].range === 0) { return false }
else { return true; }
}
if (arrows.length === 0) return false;
}
Again though, the question is: what does =>
do in this case and in general?