Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Capturing Visitor Input and Writing It to the Page

Create a variable named answer but don't put a value in it yet.

Create a variable named answer but don't put a value in it yet.

scripts.js

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>

5 Answers

Shezan Kazi
Shezan Kazi
10,807 Points

Hi,

what exactly is your question. In JavaScript you create variables with the keyword var.

For example var pi = 3.14;,

without a value just type var pi;

Tyson Ehlers
Tyson Ehlers
1,626 Points

The way I got the answer in the scripts.js tab is as follows:

var answer ='';

Good luck!

Quang Nguyen
Quang Nguyen
2,235 Points

Hi Tsai,

The way how I have solved this challenge is as of following:

<body>
  <script src="scripts.js">
    var answer;
  </script>
</body>

I hope this will help you solve this challenge with ease.

As far as I'm aware Quang, you don't need the body or script tags that you included to solve this code challenge. Just simply typing var answer ; will solve it.

var myName =""; This a correct answer