Here is some problems with it. I would like to ask you how to cope with this problem? Actually I'm new to Javascript. Thank you in advance.
It looks like this on the console:
Javascript_ Error in user.js TypeError: Cannot read property 'value' of undefined
function checkPassword(form) {
var password = checkPassword(password);
var s_letters = "qwertyuiopasdfghjklzxcvbnm";
var b_letters = "QWERTYUIOPLKJHGFDSAZXCVBNM";
var digits = "0123456789";
var specials = "!@#$%^&*()_-+=\|/.,:;[]{}";
var is_s = false;
var is_b = false;
var is_d = false;
var is_sp = false;
for (var i = 0; i < password.length; i++) {
if (!is_s && s_letters.indexOf(password[i]) != -1) is_s = true;
else if (!is_b && b_letters.indexOf(password[i]) != -1) is_b = true;
else if (!is_d && digits.indexOf(password[i]) != -1) is_d = true;
else if (!is_sp && specials.indexOf(password[i]) != -1) is_sp = true;
}
var rating = 0;
var text = "";
if (is_s) rating++;
if (is_b) rating++; //
if (is_d) rating++; //
if (is_sp) rating++; //
if (password.length < 6 && rating < 3) text = "Bad";
else if (password.length < 6 && rating >= 3) text = "Good";
else if (password.length >= 8 && rating < 3) text = "Good";
else if (password.length >= 8 && rating >= 3) text = "Excellent";
else if (password.length >= 6 && rating == 1) text = "Bad";
else if (password.length >= 6 && rating > 1 && rating < 4) text = "Good";
else if (password.length >= 6 && rating == 4) text = "Excellent";
console.log(text); // Alert will not work for us here. Console.log allows you to export data to the console for troubleshooting.
return text;
}
var player = GetPlayer(); // Gets the player object.
var myPassword = player.GetVar("SystemDate"); // Gets the value for myPassword
console.log(myPassword);
var newValue = checkPassword(myPassword); // Run the function and return to newValue
player.SetVar("SystemDate",newValue); // Set the value of newValue back to Storyline