Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Member nufftalon's Avatar
    Join Date
    Dec 2012
    Posts
    77
    Member #
    34119
    Liked
    4 times
    Think of a function as having four parts.
    1. Declare the function using var, and then give it a name.
    2. Then you must use the function keyword to tell the computer that you are making a function.
    3. The bit in the parentheses is called theparameter. Think of it as a placeholder word that we give a specific value when we call the function. See the hint for more.
    4. Then write your block of reusable code between { }. Every line of code in this block must end with a ;.

    Syntax
    var functionName = function() { code code code; code code code; (more lines of code); };
    Let's say you want to print a greeting each time a person walks past your desk. And you want to personalize that greeting with their name. Typing out:
    console.log("Hello, Betty");

    console.log("Hello, Laura");

    and so on for each person will take forever!
    1. On line 11, call the greeting function and put in a name that you want the greeting function to include.
    2. Press Run and see the function get into action! Saves you so much time.


    Hide hint

    When we want to join together two strings, we put a plus sign.
    console.log("Hey" + "you") will print out Heyyou. That's not what we want!
    If you want a space between words, you must add that space as well!
    console.log("Hey" + " " + "you") will print out Hey you
    This joining of strings is calledconcatenation

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

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

    //On line 11, call the greeting function!

    console.log("function" + " " + "Betsy")

  2.  

  3. #2
    Member nufftalon's Avatar
    Join Date
    Dec 2012
    Posts
    77
    Member #
    34119
    Liked
    4 times
    II'm not sure how to call the greeting function. I need to see some more examples to understand this. I love code academy but Im stumped lol

  4. #3
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    139 times
    For others, it can be found here: http://www.codecademy.com/courses/ja...#!/exercises/2

    The previous section (Section 2: Introducing Functions) tells you how to call a function, example: divideByThree(6);

    So you'd do:
    greeting ("James T. Kirk");
    nufftalon likes this.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  5. #4
    Member nufftalon's Avatar
    Join Date
    Dec 2012
    Posts
    77
    Member #
    34119
    Liked
    4 times
    Thank you so much I understand now I'm not supposed to print the console.log but call the greeting and the greeting in the case is equal to "great to see you" thank you so much I am just learning javascript something I probably should of done a long time ago.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

code academy call the greeting function

,

code academy greeting function

,
codecademy call the greeting function
Click on a term to search for related topics.
All times are GMT -6. The time now is 03:20 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com