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?
Alan W. Smith
25.6k5 gold badges73 silver badges101 bronze badges
asked Mar 2, 2014 at 22:26
John Smith
6,29719 gold badges63 silver badges113 bronze badges
-
You're missing a parenthesis, open the console.adeneo– adeneo2014年03月02日 22:27:32 +00:00Commented Mar 2, 2014 at 22:27
1 Answer 1
You might not like this answer but you're missing a ")"
$('body').append($('<p/>',{text: "hallo"})); <--- notice
answered Mar 2, 2014 at 22:28
Phil
11.2k18 gold badges73 silver badges106 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js