diff --git a/index.js b/index.js index 765e13650..b4c77fcc1 100644 --- a/index.js +++ b/index.js @@ -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() { @@ -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()() diff --git a/test/index-test.js b/test/index-test.js index 401d62dc3..654dbac1e 100644 --- a/test/index-test.js +++ b/test/index-test.js @@ -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() { @@ -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() { @@ -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!') }) })