[Algorithms] Two Fer
[Algorithms] Two Fer
Introduction
Two-fer
or 2-fer
is short for two for one. One for you and one for me.
"One for X, one for me."
When X is a name or “you”.
If the given name is “Alice”, the result should be “One for Alice, one for me.”
If no name is given, the result should be “One for you, one for me.”
Solutions
1var TwoFer = function () {};
2
3TwoFer.prototype.twoFer = function (who) {
4 if(who === '' ? 'you' : who)
5 return console.log(`One for ${who}, one for me.`);
6};
7
8module.exports = TwoFer;
9
10
11// Test
12TwoFer.prototype.twoFer('Jane');