Published
Edited
Aug 26, 2019
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
return 'Hello, World'
}
Insert cell
{
//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
return 5
}
Insert cell
Insert cell
Insert cell
typeof 123
Insert cell
typeof 0.1
Insert cell
typeof "this is a string" // denoted by either "string value goes in here" or 'string value in here'
Insert cell
typeof 'this is also a string'
Insert cell
typeof ""
Insert cell
typeof true // either true of false
Insert cell
typeof false
Insert cell
typeof undefined // the only undefined value is undefined
Insert cell
// `typeof` doesn't work with `null` values for backwards compatability reasons.
typeof null
// when checking if something's explicitly `null`, make sure to use null === null
Insert cell
Insert cell
6 + 3 // addition
Insert cell
6 - 3 // subtraction
Insert cell
6 * 3 // multiplication
Insert cell
6 / 3 // division
Insert cell
Insert cell
10 % 3 // If you divide 10 by 3, you get 3 and a remainder of 1
Insert cell
Insert cell
3 > 2 // 3 is greater than 2
Insert cell
3 < 2 // 3 is not less than 2 so this "outputs" or "returns" false
Insert cell
3 >= 3 // 3 is greater than or equal to 3
Insert cell
3 <= 4 // 3 is less than or equal to 4
Insert cell
Insert cell
Insert cell
Insert cell
'Bob'+'Mary'
Insert cell
"Give " + "me "+"your "+ "tired, "+"your " +"poor..."
Insert cell
Insert cell
{
// 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.
}
Insert cell
Insert cell
Insert cell
{
return 2+2
}
Insert cell
Insert cell
{
//answer here
}
Insert cell
Insert cell
{
// Your Code Here
}
Insert cell
Insert cell
{
return typof (2+2) //should return number
}
Insert cell
{
return 3-1+'4'-'3' //should return 3
}
Insert cell
{
return 'Bob ' + 'just ' + 'turned ' + 2*3-4 //should return Bob just turned 2
}
Insert cell
Insert cell
Insert cell

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.
Learn more