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

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


// COMMAND LINE UTILITY - EXTRA CREDIT
const clArgument = process.argv[2];
console.log(`Hey there from the ${clArgument}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see you used process.argv[2] to do the bonus!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since process.argv[2] is generated dynamically, it would be more appropriate to use the var key word. Const implies that a variable will not be reassigned, thus it will remain constant throughout the program.

8 changes: 8 additions & 0 deletions lab-Evan/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = exports = {};

exports.greet = function(name) {
console.log(`hello ${name}`);
return `hello ${name}`;
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are only exporting a single method, it's not necessary to use module.exports = exports = { } It would be more appropriate to use module.exports = { } since greet.js is only exporting a single method :) For instance, if you were to attach another function the exports objects, then using module.exports the way you have on line 3 would be fine.

13 changes: 13 additions & 0 deletions lab-Evan/test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

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

describe('Greet module', function() {
describe('#greet()', function() {
it('should return hey plus the name passed in', function() {
let greetingString = greet.greet('Evan');
assert.ok(greetingString === 'hello Evan', 'string does not match hello Evan');
});
});
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test looks good!