Public
Edited
Jan 26, 2024
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
for(var i=0; i<10; i++){
console.log(`Iteration number ${i}`) // Remember that the output will show up in the Console.
}
}
Insert cell
{
let currVall = 0;
for (let val = 0; val < 20; val++) {
currVall += val;
console.log("Hello World +", val, "goodbye");
}
return currVall;
}
Insert cell
{
for(var i=0; i<10; i++){
console.log(`Iteration number ${i}`) // Remember that the output will show up in the Console.
}
return i
}
Insert cell
{
let myArray = [0, 1, 2, 3, 4];
for (var i = 0; i < 5; i++) {
console.log("accessing an array", myArray[i], i); // Remember that the output will show up in the Console.
}
return myArray[i - 1];
}
Insert cell
Insert cell
{
let myArray = ["my", "new", "array"];

for (var whatever in myArray) {
console.log(myArray[whatever], whatever);
}
return myArray;
}
Insert cell
{
let array = [0, 1, 2, 3, 4];

for (var i in array) {
array[i] = array[i] ** 2;
}

return array;
}
Insert cell
Insert cell
{
var counter = 0
while(counter < 5){
console.log(`The counter is ${counter}, which is less than 5.`)
counter += 1
};
return counter
}
Insert cell
{
for(var i=0; i<5; i++){
console.log('accessing an array',i) // Remember that the output will show up in the Console.
}
}
Insert cell
Insert cell
Insert cell
{
const num = 100
if(num == 100) {
return "100!"
}
else {
return "Not 100..."
}
}
Insert cell
Insert cell
{
const num = 100
if(num == 99) {
return "99!"
}
else {
return "Not 99..."
}
}
Insert cell
Insert cell
{
var number = 100
if(number == 100){
return "Number is 100"
} else if(number < 100){
return "Number is less than 100."
} else if(number > 100){
return "Number is greater than 100."
}};
Insert cell
Insert cell

// function declaration with parameters
function multiply_this(number1, number2) {
return number1 * number2
}

Insert cell
multiply_this(5,2)
Insert cell
function empty(){
return 'hello world'
}
Insert cell
hello = empty()
Insert cell
{
// call the function, providing arguments for the parameters
const x = 4
const y = 5

return multiply_this(x,y) // run function with x and y as our arguments
}
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more