Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Calling my function?

Hey guy's so i created a function call nameString, with the parameter placeholder called (name)

When i put my own name in the parameter it give me the following error

ReferenceError: kevin is not defined, but i define the parameter when i am calling the function.

Code
var nameString = function (name) {
    return "Hi, I am" + " " + name;
    
};

nameString = kevin;

console.log (nameString);

Could anyone please help me out, i am a JS beginner but i am still getting more the hang of it.

Hand in Hand, Kameraden!
[Image: rtoT6OM.jpg]
Try calling the function like this:

Code
nameString(keven)

OR

nameString("Keven")

Not sure with or without ", been a long time since I used JS.
/thread

[Image: M6MscUn.gif]

(Jun 10, 2013 10:07 AM)๖ۣۜAlexander Wrote:  Try calling the function like this:

Code
nameString(keven)

OR

nameString("Keven")

Not sure with or without ", been a long time since I used JS.

Thank's got it already and it is without the quotation marks.

Hand in Hand, Kameraden!
[Image: rtoT6OM.jpg]
Wrong section.

Web Development

@Anon

nameString("Keven"); is correct.

@OP

nameString = "Kevin"; should fix it. Otherwise it's looking for a variable called "Kevin"

PHP Code

<?php 
var x = "I_am_a_string";
var 
I_am_a_string = x;
console.log(I_am_a_string); //I_am_a_string 

Works

PHP Code

<?php 
var x = I_am_a_string;
console.log(x); 

Does not work. You'd get an error like: "ReferenceError: kevin is not defined".


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Assembly] by samuelrizzoMay 8, 2018 12:19 PM 3 268 May 8, 2018 12:19 PM
Last Post: spiderfruit
[Assembly] by gamg7May 17, 2016 09:09 PM 1 220 May 17, 2016 09:09 PM
Last Post: brownclown
by CarlosMarti123Mar 12, 2012 12:40 PM 3 140 Mar 12, 2012 12:40 PM
Last Post: MrZander