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

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

qt - Change color of QGraphicsView rubber band -

c++ - Visible files in the "Projects" View of the Qt Creator IDE if using the CMake build system -