Earlier quoted context omitted.
I can't come up with a real world use for the .map function, but then I only use Arrays when I do evil things like writing optimized code. If I however would end up in a situation where I wanted to do: var odds = evens.map(v => v + 1); I would write this instead: var odds = increment(evens, n); But it's never as simple as this, evens would probably be some sort of async object and you probably want to call another fu…
That is a loaded example that deliberately leaves out the implementation details to disguise the productivity gains. If you really can't see the productivity difference between writing this: const vals = ['#hp','#mp','#gp'].map(x => $(x).val()); And this: var elems = ['#hp','#mp','#gp']; var getVal = function (x) { return $(x).val() }; var mtVals = []; for (var x = 0; x ... then maybe you should actually go read some…
(basically just juggling data, you should make a real world example.)
I have seen Jquery before so I know $ returns a document element. And if you pass # into it, it will return getElementById(). And .val() returns .value
So my guess is that you want to get the values of hp, mp, gp, whatever that is. I don't understand why you want them in an array though!? Wouldn't it be better to store them in an associative array? So that you don't have to remember what position in the array points to what value.
Try this instead:
var signupForm = getFormData("signupForm");
alert( "Your name is " + signupForm["name"] );
Or without the abstraction: var name = document.getElementById("name").value;
A little more characters to type, but you don't have to learn a framework to know what it does. A trick here is to use keyboard macros to do the boilerplate. Don't var PI = Math.PI because of laziness.