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 trialKupe Kouratoras
888 Pointswhat is a string
i don't really understand the question
var myname = "what is your name?";
prompt(myname);
var KJ = prompt(myname);
alert("hello " + KJ + "!");
3 Answers
eslam said
Courses Plus Student 6,734 PointsA string is a data type is javascript, data types including :
- Strings ( Strings are written with quotes. You can use single or double quotes )
"hello world"
- Numbers
10
- Booleans ( Boolean is a value its either true or false )
var x = 10;
var y = 5;
x > y // returns true
var x = 1
var y = 4;
x > y // returns false
- Arrays ( Think of an array like a list of items, arrays are written with square brackets )
var names = ["Wesam", "John", "Nahla"];
- Objects ( Think of objects like a collection of properties objects are written with curly braces )
var user = {
name: "stuve",
age: 25,
country: "sweden"
}
- Undefined ( a variable without a value, has the value undefined )
var score; // returns undefined
- Null
Null is the absence of value ( the data type of null in javascript is an object )
You can know the type of anything by using the typeof operator
typeof 5; // returns a number
typeof "hello" // returns a string
typeof ["Wesam", "John", "Nahla"] // returns object despite it's an array javascript arrays are objects
Oskar Lundberg
9,534 PointsI'm not very familiar with JavaScript, and I don't know if this will help. But the following passed the Challenge:
var myName = "Oskar Lundberg"
var myAge = 20
var message = myName + " is " + myAge
alert(message)
I hope it somehow helps :D