Created
September 23, 2013 10:07
-
-
Save pavelpower/6668614 to your computer and use it in GitHub Desktop.
Решения для тестового задания под пунктом 4
This file contains 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
var obj = { | |
index: 0, | |
words: ['blackberry', 'apple', 'orange'], | |
callCount: 0, | |
toString: function() { | |
this.callCount++; | |
this.index = this.index > this.words.length - 2 ? 0 : this.index + 1; | |
return ( this.callCount === 2 ? ' ' : '') + this.words[this.index] ; | |
} | |
}; | |
console.log('2 ' + obj === '2 apple'); | |
console.log('as is' + obj === 'as is orange'); | |
console.log(obj + ' is bad' === 'blackberry is bad'); | |
console.log(obj + ' is cool' === 'apple is cool'); | |
console.log(obj + ' color' === 'orange color'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment