0

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?

1
  • You're missing a parenthesis, open the console. Commented Mar 2, 2014 at 22:27

1 Answer 1

2

You might not like this answer but you're missing a ")"

$('body').append($('<p/>',{text: "hallo"})); <--- notice

http://jsfiddle.net/HQ9P2/1/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.