Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #2214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #2214

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
15 changes: 6 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
var animal = 'dog'

function myAnimal() {
// You should not need to modify this function
return animal
}

function yourAnimal() {
// The tests expect this function to return `animal` just like the previous function
// However, you cannot simply modify the existing variable declared on line 1 in the global scope
// How can we make sure that this function
// and the above function both pass?
// P.S.: Hard-coding 'cat' below will not work
// P.S.: You can't just hard-code 'cat' below
var animal = 'cat'
return animal
}

function add2(n) {
const two = 2
return n + two

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

var funkyFunction = function() {
Expand All @@ -27,6 +24,6 @@ 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
// We want 'funkyFunction' on the line below to return a function that returns "FUNKY!" -- how can we accomplish that?
// NOTE: To pass this final test, you only need to modify the code below this line.
var theFunk = funkyFunction()()
15 changes: 3 additions & 12 deletions test/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

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

it('does not modify the animal variable', () => {
expect(window.myAnimal.toString()).toNotContain("animal =")
})
})

describe('yourAnimal()', function() {
Expand All @@ -17,13 +13,8 @@ describe('Fix the Scope', function() {
})

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

it('does not change the output of the myAnimal function', () => {
expect(window.myAnimal()).toEqual('dog')
})
})

describe('add2(n)', function() {
Expand All @@ -39,8 +30,8 @@ describe('Fix the Scope', function() {
})
})

describe("the variable 'theFunk'", function() {
it('is equal to "FUNKY!"', function() {
describe('theFunk', function() {
it('is "FUNKY!"', function() {
expect(window.theFunk).toEqual('FUNKY!')
})
})
Expand Down