Skip to content
Open

Done #100

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ function yourAnimal() {
// How can we make sure that this function
// and the above function both pass?
// P.S.: You can't just hard-code 'cat' below
var animal = 'cat'
return animal
}

function add2(n) {
return n + two

// Feel free to move things around!
const two = 2
return n + two
}

var funkyFunction = function() {
Expand All @@ -26,4 +26,4 @@ var funkyFunction = function() {

// We want to set theFunk equal to "FUNKY!" using our funkyFunction.
// NOTE: you only need to modify the code below this line.
var theFunk = funkyFunction
var theFunk = funkyFunction()();
29 changes: 29 additions & 0 deletions index.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var animal = 'dog'

function myAnimal() {
return animal
}

function yourAnimal() {
// How can we make sure that this function
// and the above function both pass?
// P.S.: You can't just hard-code 'cat' below
return animal
}

function add2(n) {
return n + two

// Feel free to move things around!
const two = 2
}

var funkyFunction = function() {
return function() {
return "FUNKY!"
}
}

// We want to set theFunk equal to "FUNKY!" using our funkyFunction.
// NOTE: you only need to modify the code below this line.
var theFunk = funkyFunction
78 changes: 39 additions & 39 deletions test/index-test.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
/*global describe, it */

describe('Fix the Scope', function() {
describe('myAnimal()', function() {
it('returns my animal', () => {
expect(window.myAnimal()).toEqual('dog')
})
})

describe('yourAnimal()', function() {
it('returns your animal', function(){
expect(window.yourAnimal()).toEqual('cat')
})

it('does not hard-code the answer', function() {
expect(window.yourAnimal.toString()).toNotContain("return 'cat'")
})
})

describe('add2(n)', function() {
it('adds two to n', function() {
const n = Math.floor(Math.random() * 1000)
expect(window.add2(n)).toEqual(n + 2)
})
})

describe('funkyFunction()', function() {
it('returns a function', function() {
expect(typeof window.funkyFunction()).toEqual('function')
})
})

describe('theFunk', function() {
it('is "FUNKY!"', function() {
expect(window.theFunk).toEqual('FUNKY!')
})
})

})
/*global describe, it */
describe('Fix the Scope', function() {
describe('myAnimal()', function() {
it('returns my animal', () => {
expect(window.myAnimal()).toEqual('dog')
})
})
describe('yourAnimal()', function() {
it('returns your animal', function(){
expect(window.yourAnimal()).toEqual('cat')
})
it('does not hard-code the answer', function() {
expect(window.yourAnimal.toString()).toNotContain("return 'cat'")
})
})
describe('add2(n)', function() {
it('adds two to n', function() {
const n = Math.floor(Math.random() * 1000)
expect(window.add2(n)).toEqual(n + 2)
})
})
describe('funkyFunction()', function() {
it('returns a function', function() {
expect(typeof window.funkyFunction()).toEqual('function')
})
})
describe('theFunk', function() {
it('is "FUNKY!"', function() {
expect(window.theFunk).toEqual('FUNKY!')
})
})
})