Today i solved a Task on CodeFights in JavaScript and looked afterwards for a better solution. The nr.1 JS solution was this :
function allLongestStrings(inputArray) {
"use strict";
let maxValue = Math.max(...inputArray.map(x => x.length));
return inputArray.filter(x => x.length === maxValue);
}
I am quite new to Coding, but i learned some neat things from this already, like the "use strict", the map and the filter function.
But my issue so far is that i don´t 100% understand how (x => x.length)
exactly works. Is it declaring a new variable called x and applies x.length to it? Or what exactly is happening here?