shapper wrote on 22 nov 2008 in comp.lang.javascript:
I am using JQuery as follows:
do not use JQuery.
$levels = $('input[name="Levels"]:checked + label');
levels = $levels.map(function() { return $(this).text(); }).get();
$theme.append(levels.join(", ")).append('<br />');
Do you understand what you are doing here?
I sure as hell I do not.
Adding to a code you do not functionally understand
is hazardous to say the least.
$theme.append(levels.join(", ").replace(/", "$/,'"and "')).append
('<br />');
However it is not working. What am I doing wrong?
Now I can see what you ment,
levels.join(", ")
you did not add quotes to the join string,
which is not at all logical in a string join,
as there could be commas in the members,
but perhaps it is not a string join.
Try:
..replace(/, $/,'and ')
Better start debugging your code.
And perhaps also do not use regular expressions,
while you do not yet understand them.