Q:

function executes correctly in console, but not in code

I'm using the less.modifyVars() function from less.js.
In the console, I can do this:
less.modifyVars({ '@body-bg' : 'black' });

And it recompiles the less, giving a black background to the page. So that works fine.
I then try it in the code, with:
$scope.variableChange = function(selectedVariable) {
    var slug = "'" + selectedVariable.slug + "'";
    var value = "'" + selectedVariable.value + "'";
    less.modifyVars({ slug : value });
};

Now, I can see that the less.modifyVars() function does execute, because I get notifications in the console, but it doesn't seem to pass the correct values. So I add a console.log inside the variableChange function:
console.log(slug + ":" + value);

I then get the console output:
'@body-bg':'black' 

This should mean that the less.modifyVars() function is executed with:
less.modifyVars({ '@body-bg' : 'black' });

But I don't see it. What's the problem here?

A:

The way you are making your object is wrong
What you are setting is
{ "slug" : "'black'" }

You can not set a variable to be a key like that and you do not need to add extra quotes, you are just adding quotes to the string. 
Just make a object, add a key, set the value.
var obj = {};
obj[selectedVariable.slug] = selectedVariable.value;
less.modifyVars(obj);

