Created
September 18, 2017 13:19
-
-
Save DrinKaziu/615c162eecc86e2a5e7b17d9898c2b39 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xumefib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| function personMaker() { | |
| var person = { | |
| firstName: 'Paul', | |
| lastName: 'Jones', | |
| fullName: function() { | |
| return this.firstName + ' ' + this.lastName | |
| } | |
| }; | |
| return person; | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | |
| Nothing to see here! | |
| */ | |
| (function testPersonMaker() { | |
| var person = personMaker(); | |
| if (typeof person !== 'object') { | |
| console.error('ERROR: `personMaker` must return an object'); | |
| return false | |
| } | |
| if (typeof person.fullName !== 'function') { | |
| console.error('ERROR: `fullName` must be a method'); | |
| return false | |
| } | |
| if (person.fullName() !== 'Paul Jones') { | |
| console.error('ERROR: The value for `fullName` should be "Paul Jones" but was ' + person.fullName()); | |
| return false; | |
| } | |
| person.firstName = 'Lisa'; | |
| person.lastName = 'Simpson'; | |
| if (person.fullName() !== 'Lisa Simpson') { | |
| console.error( | |
| '`personMaker` is not using self reference correctly. ' + | |
| 'When firstName set to "Lisa" and lastName set to "Simpson", ' + | |
| 'should return "Lisa Simpson" but returned ' + person.fullName() | |
| ) | |
| } | |
| console.log('SUCCESS: `updateObject` works correctly!'); | |
| })(); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">function personMaker() { | |
| var person = { | |
| firstName: 'Paul', | |
| lastName: 'Jones', | |
| fullName: function() { | |
| return this.firstName + ' ' + this.lastName | |
| } | |
| }; | |
| return person; | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | |
| Nothing to see here! | |
| */ | |
| (function testPersonMaker() { | |
| var person = personMaker(); | |
| if (typeof person !== 'object') { | |
| console.error('ERROR: `personMaker` must return an object'); | |
| return false | |
| } | |
| if (typeof person.fullName !== 'function') { | |
| console.error('ERROR: `fullName` must be a method'); | |
| return false | |
| } | |
| if (person.fullName() !== 'Paul Jones') { | |
| console.error('ERROR: The value for `fullName` should be "Paul Jones" but was ' + person.fullName()); | |
| return false; | |
| } | |
| person.firstName = 'Lisa'; | |
| person.lastName = 'Simpson'; | |
| if (person.fullName() !== 'Lisa Simpson') { | |
| console.error( | |
| '`personMaker` is not using self reference correctly. ' + | |
| 'When firstName set to "Lisa" and lastName set to "Simpson", ' + | |
| 'should return "Lisa Simpson" but returned ' + person.fullName() | |
| ) | |
| } | |
| console.log('SUCCESS: `updateObject` works correctly!'); | |
| })();</script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function personMaker() { | |
| var person = { | |
| firstName: 'Paul', | |
| lastName: 'Jones', | |
| fullName: function() { | |
| return this.firstName + ' ' + this.lastName | |
| } | |
| }; | |
| return person; | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | |
| Nothing to see here! | |
| */ | |
| (function testPersonMaker() { | |
| var person = personMaker(); | |
| if (typeof person !== 'object') { | |
| console.error('ERROR: `personMaker` must return an object'); | |
| return false | |
| } | |
| if (typeof person.fullName !== 'function') { | |
| console.error('ERROR: `fullName` must be a method'); | |
| return false | |
| } | |
| if (person.fullName() !== 'Paul Jones') { | |
| console.error('ERROR: The value for `fullName` should be "Paul Jones" but was ' + person.fullName()); | |
| return false; | |
| } | |
| person.firstName = 'Lisa'; | |
| person.lastName = 'Simpson'; | |
| if (person.fullName() !== 'Lisa Simpson') { | |
| console.error( | |
| '`personMaker` is not using self reference correctly. ' + | |
| 'When firstName set to "Lisa" and lastName set to "Simpson", ' + | |
| 'should return "Lisa Simpson" but returned ' + person.fullName() | |
| ) | |
| } | |
| console.log('SUCCESS: `updateObject` works correctly!'); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment