Function syntax problem with var and fuction


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

```

Replace this line with your code.

<do not remove the three backticks above>

#2

Share your code, any errors that you are receiving, as well as any questions that you have. Then we’ll have the information we need to be able to help you.


#3

var sayGreat to see you = function (Ali) {
console.log(“Great to see you,” + " " + “Ali”);
};
i really tried a lot of ways so i can succeed but nothing worked i really do need help
i am not going to proceed working till i finish this one because i think everything is attached to each other
help me please


#4

First Problem - Variable Name

A variable is a symbol that represents (points to) some value or information. You create a variable using a contiguous string of characters. A typical coding standard is to use camelCase.

What do you notice about camelCase?

  1. It’s a contiguous string of characters, meaning no spaces between the characters.
  2. The first word’s character is in lowercase (as in camel), while the first character of other words is capitalized (as in Case).

Now look at your variable: sayGreat to see you. What’s wrong with your variable name? Try to fix it yourself.

Problem 2 - Make the Function Reusable

Instead of hard-coding a string literal of Ali, we make our function’s reusable by defining a function parameter. That parameter can accept different names. Then you use that parameter within the message that you are printing out.

Take a look at the example given to help you figure it out:

var sayHello = function(name) {
    console.log('Hello ' + name);
};

Finally, Call It

On line 11, call you function using the variable you gave it, followed by (, your name, and then the closing ).

Try it for yourself.


#5

i tried it without say it didn’t work but i didn’t understand on line 11
what should i do??


#6

How do you make a function run? The description in that lesson explains it to you.

Let’s look at the example:

var sayHello = function(name) {
    console.log('Hello ' + name);
};

and to make that run you do this:

sayHello("Emily");

Notice how you are calling the function by the variable sayHello. Then you wrap the name 'Emily' inside of the parentheses.

Okay, adapt that code pattern to your code.

Take a little time to reread the lesson. Look at the example code they give you. Then adapt that to your code.

Try it yourself.

If you get stuck, share what you have and we’ll keep working through it together.


#7

Hi
I’m having trouble with function syntax in java script.
It will run. it seems to be correct but it continues to say you did not call the greeting function. Pass it a name.
Can you help.


#8

Hey @jdimetric12,

Go ahead and create a new forum post just for your question. Make sure you share your code, any errors, and notes or questions for us too. That gives us the information we need to better help you out.

Cheers :slight_smile:


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.