What I posted above is an expression (can be recognized by {{ }}
). So you can only paste that in a parameter that you have set to be an expression.
If you want to use a Function-Node it would more look like this:
const values = [
'a',
'b',
'c',
'd',
];
items[0].json.myVariable = values[Math.floor(Math.random()*values.length)];
return items;