Debugging bad function syntax


#1

Here is the code given:

// Nicely written function:
var calculate = function (number) {
    var val = number * 10;
    console.log(val);
};

// Badly written function with syntax errors!

greeting var func{name}(console.log(name)))}

....Does anyone know how to debug line 9 -- greeting var func{name}(console.log(name)))} -- and fix the syntax?


#2

can you gist your code? it looks to me as if there are some problems with the curly braces and the parenthesis bude i'd like to look at the line in context :wink:


#3

to me without knowing seeing your code this would make sense:-

var greeting = function(name){ console.log(name);}


#4

Just edited to use the preformatted text button. Try to always use it :smile:
As @paddydrum said it is missing an opening brace {

All functions need an opening and closing {} to show what code needs to be run when the function is called.


#5

to add to that alex when I was taught to code my lecturer said when writing code if you create an open brace add the closing one to start with and write between so you don't get mixed up :wink: