feat: works
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
add: function (a, b) {
|
||||
return a + b;
|
||||
},
|
||||
subtract: function (a, b) {
|
||||
return a - b;
|
||||
},
|
||||
multiply: function (a, b) {
|
||||
return a * b;
|
||||
},
|
||||
divide: function (a, b) {
|
||||
return a / b;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
//load module
|
||||
let calc = require("./scripts/calc.js");
|
||||
|
||||
console.log("Using calc module");
|
||||
console.log("Add: " + calc.add(3, 3));
|
||||
console.log("Subtract: " + calc.subtract(3, 3));
|
||||
console.log("Multiply: " + calc.multiply(3, 3));
|
||||
console.log("Divide: " + calc.divide(3, 3));
|
||||
@@ -0,0 +1,11 @@
|
||||
//access custom global variable
|
||||
console.log("Custom global: " + customstring);
|
||||
|
||||
//call a custom global function with arguments
|
||||
console.log("Custom function: " + rusty_hello("Boa! Boa!"));
|
||||
|
||||
//access a custom global object and call a member function of that object
|
||||
let a = 5;
|
||||
let b = 5;
|
||||
let result = rusty_obj.add(a, b);
|
||||
console.log("Custom object: Result from rusty_obj.add() : " + result);
|
||||
@@ -0,0 +1 @@
|
||||
console.log("Hello World from JS file!");
|
||||
Reference in New Issue
Block a user