Published
Edited
Sep 23, 2019
6 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//notice that Dog only really defines the introduce attribute
dog =
{
var dog = {
introduce: function() {
return 'Hai, I am a Dog!'
}
}
Object.setPrototypeOf(dog,animal)
return dog;
}
Insert cell
Insert cell
dog.makesSound
Insert cell
dog.mustEat
Insert cell
Insert cell
dog.introduce()
Insert cell
dog.introduce()===animal.introduce()
Insert cell
Insert cell
Insert cell
cat = {
//your code goes here
}
Insert cell
{
if(cat===undefined)
return "Your function will be unit tested here"
try
{
expect(cat).to.have.own.property('meow')
expect(cat).to.have.own.property('purr')
expect(cat).to.have.own.property('mood')
expect(cat).to.have.own.property('tummyRub')
cat.tummyRub()
expect(cat.mood).to.equal('happy')
expect(cat).to.have.property('mustEat')
expect(cat).to.have.property('isAlive')
expect(cat).to.have.property('makesSound')
expect(cat).to.not.have.own.property('mustEat')
expect(cat).to.not.have.own.property('isAlive')
expect(cat).to.not.have.own.property('makesSound')
expect(cat.introduce().toLowerCase()).to.include('cat')
return success()
}
catch(err)
{
return failure()
}
}
Insert cell
Insert cell
Insert cell
accountantKitty = {
//your code goes here
}
Insert cell
{
if(accountantKitty===undefined)
return "Your function will be unit tested here"
try
{
expect(accountantKitty).to.have.own.property('name')
expect(accountantKitty).to.have.own.property('addTwoNumbers')
expect(accountantKitty).to.have.own.property('attachKittyToAnArray')
expect(accountantKitty).to.have.own.property('mustEat')
expect(accountantKitty).to.have.property('isAlive')
expect(accountantKitty).to.have.property('makesSound')
expect(accountantKitty).to.not.have.own.property('isAlive')
expect(accountantKitty).to.not.have.own.property('makesSound')
expect(accountantKitty).to.have.property('meow')
expect(accountantKitty).to.have.property('purr')
expect(accountantKitty).to.have.property('mood')
expect(accountantKitty).to.have.property('tummyRub')
expect(accountantKitty).to.not.have.own.property('meow')
expect(accountantKitty).to.not.have.own.property('purr')
expect(accountantKitty).to.not.have.own.property('mood')
expect(accountantKitty).to.not.have.own.property('tummyRub')
accountantKitty.tummyRub()
expect(accountantKitty.mood).to.equal('happy')
expect(accountantKitty.addTwoNumbers(2,4)).to.equal(6)
expect(accountantKitty.attachKittyToAnArray([2,5,"bob"])).to.equal([2,5,"bob", "kitty"])
expect(accountantKitty.introduce()).to.include(accountantKitty.name)
return success()
}
catch(err)
{
return failure()
}
}
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