How to call the nested isPasswordValid() function in users.js from test.js file
users.js
'use strict';
var zxcvbn = require('zxcvbn'),
httpStatus = require('http-status-codes');
module.exports = function (users) {
function isPasswordValid(password) {
var passwordValidatorResult = zxcvbn(password);
console.log('score: ', passwordValidatorResult.score);
//if score is less than 3 then reject the user creation request
if (passwordValidatorResult.score < 3) {
return passwordValidatorResult.feedback;
} else {
return true;
}
}
}
test.js
var user = require('./users.js');
var res = user().isPasswordValid('234fdsf');
// Not working
if(var == true)
{
console.log('Valid');
} else {
console.log('Invalid');
}
How to call nested function isPasswordValid nd
via spacedev
No comments:
Post a Comment