$.map creates a new array based on the return value of the function, using the format newarray = $.map( array, function );
The array in the sample is the jQuery selector (which is array-like). The function iterates through the members of the array, with the index passed in as "i" and the member element as "n". The function returns n.name + "=" + n.value if n.name doesn't have "_test" in it. If it does have "_test" in the name, then it returns "some_value" that has been predefined. Its just a simple ternary statement: value = condition?true:false; HTH :) On Apr 13, 6:38 pm, Nic Hubbard <nnhubb...@gmail.com> wrote: > Could you explain this one a little more? How you coded it is a > little confusing to me. > > On Apr 13, 6:34 pm, mkmanning <michaell...@gmail.com> wrote: > > > If I understand you code, you're trying to create an array of > > name=value, with value being specifically set if the name has _test in > > it? > > > var arr = $.map($('input'),function(n,i){ > > return > > n.name+'='+(n.name.indexOf('_test')!=-1?'some_value':n.value); > > > }); > > > On Apr 13, 5:27 pm, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > > I have input values that I am adding to a array. I would like to be > > > able to check if any of them end in _test and if so, I need to set a > > > specific value. Is there any, in an if statement, to check if an > > > attribute of one of the input fields ends with _test? > > > > main_form.find('input').each(function() { > > > arr_current_item2.push($(this).attr('name') + '=' + $(this).val()); > > > > });// End each