javascript - Function bringing back error 'token {'? -


i'm new javascript , i'm having hard time functions. tried this:

(function data {     // part that's broken seems?                 var data = 1;                 var real = 2;                 console.log(data + real) // }) 

i error: uncaught syntaxerror: unexpected token {

i'm not sure means though?

seems me, bit confused brackets... try this:

function data(){     var data = 1;     var real = 2;     console.log(data+real); } 

the error suggests there problem token didn't expect there...

hope helps!


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -