let isValidPassword = function (password) {
if (password.length <= 8 && password.includes('password')) {
console.log('Password is not according to Company Policy.');
} else {
console.log('Password is accepatble!');
}
}
isValidPassword();
Here password.length is not working.
Error is : TypeError: Cannot read property 'length' of undefined at isValidPassword (C:\Users\Gitanshu Choudhary\Desktop\modern_js\hello_earth.js:163:18) at Object. (C:\Users\Gitanshu Choudhary\Desktop\modern_js\hello_earth.js:169:1) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) at internal/main/run_main_module.js:17:11
isValidPassword()without any arguments. Hence,passwordis undefined. - strisValidPassword('you password')- Afia