//this is a comment. It allows us to write human-readable text that doesn't mean diddly-squat to the computer.
//For example, I can use this comment to explain that the line below returns a number
return5
}
typeof123
typeof0.1
typeof"this is a string"// denoted by either "string value goes in here" or 'string value in here'
typeof'this is also a string'
typeof""
typeoftrue// either true of false
typeoffalse
typeofundefined// the only undefined value is undefined
// `typeof` doesn't work with `null` values for backwards compatability reasons.
typeofnull
// when checking if something's explicitly `null`, make sure to use null === null
6+3// addition
6-3// subtraction
6*3// multiplication
6/3// division
10%3// If you divide 10 by 3, you get 3 and a remainder of 1
3>2// 3 is greater than 2
3<2// 3 is not less than 2 so this "outputs" or "returns" false
3>=3// 3 is greater than or equal to 3
3<=4// 3 is less than or equal to 4
'Bob'+'Mary'
"Give "+"me "+"your "+"tired, "+"your "+"poor..."
{
// Like so:
return"this is my answer"
// This allows the value to be printed in this notebook.
// This isn't a JavaScript feature but rather a quirk of this website.
}
{
return2+2
}
{
//answer here
}
{
// Your Code Here
}
{
returntypof(2+2)//should return number
}
{
return3-1+'4'-'3'//should return 3
}
{
return'Bob '+'just '+'turned '+2*3-4//should return Bob just turned 2
}
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.