2

I'm trying to create userCount value and i want to share this value with mupltiple file

users.js

var userCount=0;

function increment() {
    userCount++;
}

module.exports.userCount=userCount;

a.js

var users = require('users');
//connection opened
users.userCount++;
log(users.userCount)  //1
// close connection

b.js

 var users = require('users');
    //connection opened
    log(users.userCount)  // the value is 0 i want the count to be  1

I'm not expert with NodeJs neither with javascript

I'm scary for misunderstanding because i don't see this question in any site

Thanks for help

Ammar
  • 27
  • 8

0 Answers0