What is wrong with this line?

Hi I have this line

var datasets = xmlhttp.responseText.match(/^#(.[^#]*)/gm).map(function(item) { return eval("(" + item.replace(/^#/,'') + ")"}));

But it complains and says that is is expecting another β€˜)’ so where is the problem? :stuck_out_tongue:

You can check the script here

http://www.tdsoft.se

Whenever I get an error like that and I really don’t see it, I start smearing the code over as many lines as possible, indenting on every (, ), { and }. Usually that will make the error obvious fairly fast.

In this case


var datasets = 
xmlhttp.responseText.match
(
	/^#(.[^#]*)/gm).map
	(
		function(item)
		{
			return eval
			(
				"(" + item.replace
					(
						/^#/,''
					)
				 + ")"
			[COLOR="Red"]// there should be a closing parenthesis here, but there isn't !![/COLOR]
		}

	)
);

So it should be:


var datasets = xmlhttp.responseText.match(/^#(.[^#]*)/gm).map(function(item) { return eval("(" + item.replace(/^#/,'') + ")") }));