In this simple example I have a function that returns a text string. When I try to output the result of the function it just outputs the code of the function. Any ideas?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
not
The former is outputting the result of the function call. The latter is outputting a reference to the function itself. You weren’t invoking it.
As a sidenote,
document.writeis very old school and has almost no use these days. If you’re new to JavaScript I would suggest looking into other means of output such as DOM scripting, e.g.