Intro to Functions: Typing it all together


#1

Here i don't know what I am doing wrong, can someone help me out here please

// 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)))}

2. How to call the greeting function when the above is fixed?

3. What does SYNTAX ERROR: "missing before statement" mean

The answer I gave was

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

I don't know what I am doing wrong here please help!!


#2

Hi here

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

after it you should call it (the function greeting)


#3

what do you mean by "after it you should call it (the function greeting)"?


#4

When you write a function you want that the function print or return something so for example

//Here I create a function planet
var planet = function(from) {
   console.log(from);
};
//here I will call the function so that it will print something
planet("Earth");

#Output
Earth

#5

ohhh ok now i got it :slight_smile: thank you :slight_smile:


#6

But when i type in my answer it says SYNTAX ERROR: missing before statement


#7

can you post your new code?


#9

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


#10

HI thsi line

var greeeting = function(name)

you wrote greeeting instead of greeting


#11

ohh oops ok ill fix it and try again


#12

It's still saying the same thing after I fixed it

This is the instructions that was given for the above

      
        Instructions
  1. A big part of programming is debugging. That just means
    figuring out what the heck went wrong with your code. Why didn't it run?

  2. Look at line 9. It has many syntax errors. See how lack of spacing makes debugging hard?

  3. Fix the function on line 9. Make sure the syntax is right. Make sure it looks nice.

  4. Call the greeting function once it is fixed! Don't forget to pass in a specific name.


#13

can you post all your code not just this part..


#14

that was all i had given for the answer... I was stuck and i still am, and I don't know how to answer this question...


#15

yes but can I see all your code..


#16

All code? I'm not getting you...

because they are only telling me to fix this code here and call a "greeting" function

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


#17

yes I know and you did it

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

but maybe you change something (or it's still missing osmething) in the function that was already there the calculate function so that why I want to see all your code...


#18

ohh ok, but when I am entering its giving the same syntax error and now I'm just a little bit confused...


#19

I can't help you or pointing where the error is if I don't see the code..