-
-
Save iam-peekay/a81faaae9c5937bb155e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib/counter.js | |
var counter = 1; | |
function increment() { | |
counter++; | |
} | |
function decrement() { | |
counter--; | |
} | |
module.exports = { | |
counter: counter, | |
increment: increment, | |
decrement: decrement | |
}; | |
// src/main.js | |
var counter = require('../../lib/counter'); | |
counter.increment(); | |
console.log(counter.counter); // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
counter.counter will have value of 2