-2

I am new to programming-and using codeademy to help with that so pardon me if this question is a bit of an obvious one. I mainly want to be able to call a function. I have copy and pasted the code academy stuff below and I mainly want to know what I have to do to "call the greeting function". If you could explain exactly what to do any why, that would be great.

Below is the greeting function!
// See line 7
// We can join strings together using the plus sign (+)
// See the hint for more details about how this works.

var greeting = function (name) {
console.log("Great to see you," + " " + name);
};

// On line 11, call the greeting function!`
3
  • 3
    You should read the documentation more carefully...a little trial and error effort from your side would have helped you... Commented Aug 15, 2013 at 17:52
  • 1
    You should have paid more attention in the first part of that exercise: codecademy.com/courses/javascript-beginner-en-6LzGd/0/2#!/…. It shows you exactly how to invoke a function. In the next slide (the one you're mentioning) they give you another function and ask you to invoke it using the same approach as the last slide. Commented Aug 15, 2013 at 17:55
  • the question title is very general read FAQ stack overflow [ how to ask](stackoverflow.com/questions/how-to-ask) Commented Aug 15, 2013 at 18:10

4 Answers 4

5

To call the greeting function this is all you need to do:

greeting("My Name"); // will call the function and produce "Great to see you, My Name");
Sign up to request clarification or add additional context in comments.

Comments

2

In javascript you call a function like this:

greeting("your name here");

In general, if you have a function, the syntax is function(argument1, argument2, ...);

Comments

0

these are the basic.by simple efforts on Google you can find out the answer but anyways, you can call your function like this .

 greeting("your name");

Comments

0

I got it. Now i know how to call a function. I got my answer right.

var greeting = function (name) {
    console.log("Great to see you," + " " + name);
};

// On line 11, call the greeting function!
var greeting = function (name) {
    console.log("Great to see you," + " " + "Deneb");
};
greeting("Deneb");

To call a function we always need to type the function like"Greeting","myUser" etc and then give it the function parameter. This is what i did.

1 Comment

you can edit your answer (vs. posting new ones with more or less the same content :-) Now, that you know it, you can delete the others ... assuming this here is the final? Hmm .. anyway, this looks quite similar to much earlier answers by others? Care to explain why/how it differs?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.