Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Function problems (scroll) NEW NAME

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #45813
    Attila Hajzer
    Participant

    http://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/3?curriculum_id=506324b3a7dffd00020bf661#

    I’m kinda stuck on this can someone help me?
    i’m thinking its this : but its not working. i know i’m wrong just dont know where

    var greeting;
    var name =”Attila”

    #140204
    Alen
    Participant

    You would call it like `greeting(‘Attila’);`

    #140210
    TheDoc
    Member

    It would look like this:

    var greeting = function (name) {
    alert(‘Hello, ‘+name);
    }

    greeting(‘Jiggins’);

    #140228
    TheDoc
    Member

    What are you really asking here? In the example you provide above, you don’t need to create a new var for `val` because you can just console log `name` directly.

    #140230
    TheDoc
    Member

    Right, because all you’ve done is create a function. You then have to actually *call* the function, like this:

    greeting(‘Jiggins’);

    So the final correct answer would be:

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

    greeting(‘Jiggins’);

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.