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

Basic arithmetic #431

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ five.discography(); //['5ive', 'Invincible', 'Kingsize']
five.singles(); //['Slam Dunk (Da Funk)', 'When the Lights Go Out', 'Got the Feelin\'', 'Everybody Get Up', 'It\'s the Things You Do', 'Until the Time Is Through', 'If Ya Gettin\' Down', 'Keep On Movin\'', 'Don\'t Wanna Let You Go', 'We Will Rock You', 'Let\'s Dance', 'Closer to Me', 'Rock the Party', 'I Wish It Could Be Christmas Everyday']
five.famous(); // ['Julian', 'Dick', 'George', 'Anne', 'Timmy']
five.fiveFiveFive(); // 'Interstella 5555: The 5tory of the 5ecret 5tar 5ystem'
five.five().five().five().five().toString(); // '55555'
```

##### Rotation
Expand Down
17 changes: 17 additions & 0 deletions five.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,23 @@

five.bucks = function() { return '$' + five() + '.00'; };

five.five = function () {
var self = {
total: "55",
};

function five() {
self.total += "5";
return self;
}

self.five = five;
self.toString = function () {
return self.total
};
return self;
};

five.valueOf = five;

if(typeof module !== 'undefined' && module.exports) {
Expand Down
4 changes: 4 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ assert.equal(five - five, 0);
assert.equal((five / five) * (five), five);
assert.equal(120, five.factorial());

assert.equal(five.five().toString(), "55", "Five and five makes fifty-five");
assert.equal(five.five().five().toString(), "555", "Three fives makes five hundred and fifty-five");
assert.equal(five.five().five().five().toString(), "5555", "Four fives makes five thousand, five hundred and fifty-five");

var fiveEmitter = five.emitter();
var emitterTested = false;

Expand Down