Public
Edited
Sep 18, 2024
Insert cell
Insert cell
{const greetings ="Hello World";
return greetings;
}
Insert cell
observableGreeting = "Welcom";
Insert cell
observableSentense = observableGreeting+" to coding!"
Insert cell
{
const greetings ="Hello!"
return greetings.length
}
Insert cell
{
const greetings ="🖖"

return greetings.length
}
Insert cell
{
const secondsPerMinute = 60,
minutesPerHour = 60,
hoursPerDay = 24,
daysPerWeek = 7,
weeksPerYear = 52,

secondPerYear =
secondsPerMinute*
minutesPerHour*
hoursPerDay*
daysPerWeek*
weeksPerYear

return secondPerYear
}
Insert cell
{
const illinoisRetailTax = 0.0625;
const cookCountyRetailTax = 0.0175;
const chicagoRetailTax = 0.0125;
const regionalRetailTax = 0.01;

const totalTaxRate =
illinoisRetailTax+
cookCountyRetailTax+
chicagoRetailTax+
regionalRetailTax;

const subTotal = 99.99;
const taxedTotal = subTotal * (1+ totalTaxRate)
return taxedTotal
}
Insert cell
Insert cell
{
const illinoisRetailTax = 0.0625;
const cookCountyRetailTax = 0.0175;
const chicagoRetailTax = 0.0125;
const regionalRetailTax = 0.01;

const totalTaxRate =
illinoisRetailTax+
cookCountyRetailTax+
chicagoRetailTax+
regionalRetailTax;

const subTotal = 99.99;
const taxedTotal = subTotal * (1+ totalTaxRate)
return "$" + taxedTotal.toFixed(2);
}
Insert cell
{
const illinoisRetailTax = 0.0625;
const cookCountyRetailTax = 0.0175;
const chicagoRetailTax = 0.0125;
const regionalRetailTax = 0.01;

const totalTaxRate =
illinoisRetailTax+
cookCountyRetailTax+
chicagoRetailTax+
regionalRetailTax;

const subTotal = 99.99;
const taxedTotal = subTotal * (1+ totalTaxRate)
return "The Grand Total is: $" + taxedTotal.toFixed(2);
}
Insert cell
{return "When we add one and one, we would probably expect the answer to be " + (1 + 1) + ", but sometimes we might want " + ("1" + "1") + " instead.";}
Insert cell
{
return "pi is the floating point number " + Math.PI +
"\n but it can be representated as a String: " + String(Math.PI) +
"\n or as an integer: " + parseInt(Math.PI) +
"\n or as a fixed precision float: " + parseFloat(Math.PI).toFixed(2) +
"\n or as a Greek letter: " + "π" +
"\n or as an emoji: " + "🥧";
}
Insert cell
Insert cell
{const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];
return worldGreetings;
}
Insert cell
{const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

return (
"This dataset includes " + worldGreetings.length + " words for hello");
}

Insert cell
{const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

return (
"The first item is " + worldGreetings[0] + " and the third item is " + worldGreetings[2]
);

}
Insert cell
{const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

return (worldGreetings);

}
Insert cell
{const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

return ("The last item is " + worldGreetings[8]);

}
Insert cell
{
const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

worldGreetings.push ("Kamusta");
return (worldGreetings);
}
Insert cell
{
const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];
worldGreetings[1] = "ola";
worldGreetings[3] = "konnichi wa";

return (worldGreetings);
}
Insert cell
{
const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

worldGreetings[200]= ("ola");
return worldGreetings.length;
}
Insert cell
{
const worldGreetings = [
"bonjour",
"salut",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha" ];

worldGreetings[200]= ("ola");
return worldGreetings[124];
}
Insert cell
Insert cell
{
const countUp = [];
for(let i=0; i<5 ;i=i+1 ) {
countUp.push(i);
}

return countUp;
}
Insert cell
Insert cell
{
const decreasingEven36to22 = [];
for(let i=36; i>=22; i=i-2) {
decreasingEven36to22.push(i)
}
return decreasingEven36to22;
}
Insert cell
Insert cell
{
const worldGreetings = [
"bonjour",
"jambo",
"swasdi",
"merhaba",
"allianchu",
"maakye",
"nihao",
"aloha"
];

const languages = [
"french",
"swahili",
"thai",
"turkish",
"quechua",
"twi",
"mandarin",
"hawaiian"
];

const factoids = [];

for (let i=0; i<worldGreetings.length; i = i+1) {
factoids.push(
"the word for hello in " + languages[i] + " is " + worldGreetings[i]
);
}
//return factoids;
}
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