Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Quickstart Data Types and Variables Creating Variables

How do you create a new variable?

I have typed in var = 'myage' to create a new variable and then add a string with var response = '43' but keep getting an error message

scripts.js
var = 'myAge'
var response = '43'

2 Answers

Edgardo Serafin
seal-mask
.a{fill-rule:evenodd;}techdegree
Edgardo Serafin
Full Stack JavaScript Techdegree Student 11,880 Points

You are close, the only thing is that you split it into two variables when if you combine them, you'll have the correct answer

you have the ability to name your variables, so an example would be

var fruit = 'apple';

now keep this in mind for your name

I think the conceptual issue here is fully understanding a string and what makes it a string..

The big concept of a string is that you surround it with '' or "" to create the string, and strings can be STORED in a variable. Think of the variable as a box, and in that box you can store things like strings, numbers, booleans, etc....

So should a variable be a string? Or is a variable something different? As of right now, you are assigning your variable to be a string.

I hope this helps steer you in the correct direction! :) Happy coding!

if myAge is what you want your variable to be. The response should be what you store in variable myAge

example: var variableName = 'random string you would like to store in the variable named variableName'

console.log(variableName);

output: random string you would like to store in the variable named variableName