Question | Click to View Answer |
Create a function a() {
return "This is A";
}
module.exports.a = a;
Create a |
Contents of the const path = `${process.env.HOME}/Desktop/fun_m/a.js`;
const ourNamespace = require(path);
console.log(ourNamespace.a());
The The node ~/Desktop/main.js
|
Create a module.exports = {
fullName: function(first, last) {
return `${first} ${last}`;
}
}
Update the |
Contents of the const path = `${process.env.HOME}/Desktop/fun_m/b.js`;
const moe = require(path);
console.log(moe.fullName("pam", "anderson"));
The |
Create a class Calculator {
add(a, b) {
return(a + b);
}
}
module.exports = Calculator;
Update the |
Contents of the const path = `${process.env.HOME}/Desktop/fun_m/c.js`;
const Bort = require(path);
const myBort = new Bort();
console.log(myBort.add(3, 4));
|
Use the os core module to print the hostname to the console. |
const os = require('os');
console.log(os.hostname());
The |
Create a {
"name" : "myModule",
"main" : "./stimpy.js"
}
Create a module.exports = {
speak: function() {
return "happy, happy, joy, joy";
}
};
Update the ~/Desktop/main.js file to use the |
Contents of the const path = `${process.env.HOME}/Desktop/fun_m`;
const fun = require(path);
console.log(fun.speak());
The |