Published
Edited
Sep 1, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
var bob = 100
while(bob>0)
bob=bob-2
//return bob
}
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
Insert cell
Insert cell
Insert cell
Insert cell
{
var bob = {name: "Bob", emotion: "Nauseous", species: "Hooman"}
return bob
}
Insert cell
Insert cell
{
var bob = {
name: 'Mr. Bobz',
caffeinated: true
}
// return bob.caffeinated
}
Insert cell
Insert cell
function eat() { return "WHERE IS MY NOMS?"}
Insert cell
{
var bob = {name: "Bob", emotion: "Hangry", eat: function() {return "Om nom nom"}}
return eat()
}
Insert cell
{
var bob = {name: "Bob", emotion: "Hangry", eat: function() {return "Om nom nom"}}
return bob.eat()
}
Insert cell
Insert cell
{
var bob = {
name: 'bobz',
hangry: false,
eat: function() {
return hangry;
}
}
return bob.eat()
}
Insert cell
Insert cell
{
var bob = {name: "Bob", emotion: "Hangry", eat: function() {this.emotion = "Full"}}
bob.eat()
return bob.emotion
}
Insert cell
Insert cell
thisOutOfContext = function() {
// what could `this` be?
return this;
}
Insert cell
Insert cell
{
var doggo = {
bark: function() {
return this.sound
},
sound: 'wooof!'
}
var doggoII = {
bark: doggo.bark,
sound: 'not wooof!'
}
return doggoII.bark()
}
Insert cell
Insert cell
Insert cell
Insert cell
superCat = function() {
var superCat =
{
//write code here
}
return superCat;
}
Insert cell
{
if(superCat().name === undefined)
return "Your function will be unit tested here"
try
{
var superKitty = superCat();
var kName = superKitty.name;
var kPurr = superKitty.purrStrength;
var kGloss = superKitty.coatGlossLevel;
expect(superKitty).to.have.property("name")
expect(superKitty).to.have.property("purrStrength")
expect(superKitty).to.have.property("coatGlossLevel")
//tests runThroughMud()
superKitty.runThroughMud()
expect(superKitty.purrStrength).to.be.below(kPurr)
expect(superKitty.coatGlossLevel).to.be.below(kGloss)
//tests changeName twice (cat name can be the first value by default)
superKitty.changeName('bobbbbyyyyyy')
expect(superKitty.name).to.equal('bobbbbyyyyyy')
superKitty.changeName('vanillaJim')
expect(superKitty.name).to.equal('vanillaJim')
//resets variables (because superKitty values changed after runThroughMud())
kPurr = superKitty.purrStrength;
kGloss = superKitty.coatGlossLevel;
//tests freeSpaDay()
superKitty.freeSpaDay()
expect(superKitty.purrStrength).to.be.above(kPurr)
expect(superKitty.coatGlossLevel).to.be.above(kGloss)
return success()
}
catch(err)
{
return failure()
}
}
Insert cell
Insert cell
superDoggo = function ()
{
var superDog =
{
//Write Code here
}
return superDog
}
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