Published
Edited
Feb 11, 2020
Insert cell
Insert cell
Insert cell
function mystery(input) {
var ret = ""
input++
for (var i = 0; i<20; i++)
{
input--
}
while(input>0)
{
ret = ret + (input==true) + " "
input = input-5
}
return ret
}
Insert cell
function mysteryObject() {
var ret = {
name: 'Sammy',
money: -10000,
occupation: 'Student',
mood: 'Sad'
}
if(ret.money > 0) {
ret.mood = 'relieved'
}
else {
ret.mood = 'still sad'
}
ret.getMoney = function() {
this.money = this.money + 1000
return this.money
}
return ret
}
Insert cell
function blackBox(input1, input2) {
var obj = {
name: input1,
isCrazy: input2,
getsLoopyOnFrootLoops: function(cerealBrand) {
if(cerealBrand==='Froot Loops' && this.isCrazy===true)
return true;
return false;
}
}
return obj;
}
Insert cell
Insert cell
{
var orderedNumberList =
{
first: 1,
second: 2,
third: 3,
fourth: 4,
fifth: 5,
sixth: 6,
seventh:7,
eighth: 8,
ninth: 9,
tenth: 10
}
return orderedNumberList;
}
Insert cell
Insert cell
orderedNumberList = [1,2,3,4,5,6,7,8,9,10]
Insert cell
otherArray= [2,1,3,4,5,6,7,8,9,10]
Insert cell
Insert cell
orderedNumberList.indexOf(4);
Insert cell
orderedNumberList[2]
Insert cell
Insert cell
{
var orderedNumberList = [1,2,3,4,5,6,7,8,9,10]
return orderedNumberList[9];
}
Insert cell
Insert cell
wonkyArray = ["bob", -2.5, true, "Solly the Sexy Saxaphone"]
Insert cell
Insert cell
emptyArray = [] //this is how we declare an empty array
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
theirArmy = ["dog1","dog2","dog3","dog4"] //do not change
Insert cell
ourArmy = ["superKitty"] //do not change
Insert cell
Insert cell
allAnimals = ourArmy.concat(theirArmy)
Insert cell
Insert cell
allAnimalsII = allAnimals.concat("superDoggo")
Insert cell
Insert cell
allAnimalsIII = allAnimalsII.indexOf("superKitty")
Insert cell
Insert cell
allAnimalsIV = allAnimalsII.splice(0,5)
Insert cell
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