Reputation: 6269
I thought it would be handy if I define my function, so that I can pass hashes to it. With the idea that later on when I extend my code I can easily pass more variables without having to change my other code that also executing this code.
Now I made an example, but somehow it won't work:
function test(data){
if(data.id){
$('body').append($('<p/>',{text: "hallo"});
}
};
test({id: 5, text: 4});
Fiddle: http://jsfiddle.net/HQ9P2/
What do I do wrong? And is this the right way to avoid cohesion in my code?
Upvotes: 0
Views: 975
Reputation: 11175
You might not like this answer but you're missing a ")"
$('body').append($('<p/>',{text: "hallo"})); <--- notice
Upvotes: 2