Skip to content

Instantly share code, notes, and snippets.

@pavelpower
Created September 23, 2013 10:07
Show Gist options
  • Save pavelpower/6668614 to your computer and use it in GitHub Desktop.
Save pavelpower/6668614 to your computer and use it in GitHub Desktop.
Решения для тестового задания под пунктом 4
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