Skip to content
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
6 changes: 6 additions & 0 deletions lab-regan/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

const welcome = require('./lib/greet.js');


welcome.greet('regan');
24 changes: 24 additions & 0 deletions lab-regan/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

module.exports = {};

//original solution - works!
// module.exports.greet = function(name){
// return `hello ${name}`;
// };

//bonus solution - works!
// module.exports.greet = function(){
// console.log(`hello ${process.argv[2]}`);
// };

//original + bonus solution combined - works!
module.exports.greet = function(name){
if (process.argv[2]){
console.log(`hello ${process.argv[2]}`);
return `hello ${process.argv[2]}`;
} else {
console.log(`hello ${name}`);
return `hello ${name}`;
}
};
14 changes: 14 additions & 0 deletions lab-regan/test/greet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const welcome = require('../lib/greet.js');

const assert = require('assert');

describe('Greet Module', function(){
describe('#sayHello', function(){
it('Should return "hello regan"', function(){
var outcome = welcome.greet('regan');
assert.ok(outcome === 'hello regan', 'not equal to "hello regan"');
})//end it
})//end describe - '#sayHello'
})//end describe - 'Greet Module'