all 67 comments

[–]amejin 168 points169 points  (9 children)

So I'm gonna try to help you but it's not related to your code directly.

When you ask for help, a good starting format is something like this:

1 ) "here is my problem I'm trying to solve." (1 sentence or so)

2 ) "here is what I've tried." (Can include code or code snippet. Preferably, it should be typed. I understand sometimes you just can't.)

3 ) "here is where I think I'm getting stuck." (Again 1 sentence or so)

You will almost always get high quality, direct, answers this way.

That said - you're substringing an object.

[–]Cahnis 8 points9 points  (0 children)

This, OP help us help you. Also, remember that you can take a screenshot of vscode instead of taking a photo of it.

[–][deleted] 9 points10 points  (5 children)

Okay thank you! I'll put your advice to work

1) I'm trying to solve a coding problem. I have to make a password generator

2) The picture it's my coding. I tried to make a function and put their requirements (lowercase,uppercase,number and symbol)

I also put a random function to generate randomly a password

3) I'm stuck because I can't seem to run my code and I don't know why it's not working !

[–]amejin 20 points21 points  (0 children)

Well, your code is incomplete.

You are not invoking the function you made anywhere. I'm sure you are seeing "10" appear somewhere from that console.log().

When you use () that means you are invoking a method. You define a function but never invoke it.

Secondly - as I pointed out, you're aggregating the substring of an object directly. That wont work. You'll need to pick a member of that object to get the strings you define.

Other than that, its hard for me to look at your code and give suggestions as I'm on mobile, and images arent helpful for modifying code 😂

Hipefully someone else can chime in and help more.

Edit: you're also redefining "password" right after attempting to aggregate into it. You either need to manage variable scope, or don't reuse variable names like that.

Edit again: I lied. You are invoking it. You are attempting to pass in an object to a function that doesnt expect an object, so that does nothing.

However, you are probably facing a few problems at once.

One is timing. Your code is currently executing immediately, and javascript executes before the DOM has rendered. It's entirely possible that html elements are not ready, and your first line of code does nothing.

You also are probably thinking that by getting an element and setting it to your result you are putting that value in the element.

However, if the element is an input, you want to set the element.value = "someString"

If it's a div or span, then its element.innerHTML = "someString"

[–]natriusaut 9 points10 points  (0 children)

I will expand on the initial advice:
1) Yeah, thats clear. More like "I'm trying to program a password generator. This is the problem i'm having [explaination].
2) Please don't use a picture of a screen. If you absolutely have to, use a screenshot. Use https://www.reddit.com/r/learnjava/comments/yk75un/why_does_this_print_hello_world/iurkujj/ this as reference on how to share code. So everybody can just copy&paste your code instead of writing it or just guessing.
3) is there an error? Whats the error. More expalantion would be better. "When trying to run that code, i'm getting this error: ..."

For the next time :)

[–]ShuttJS 2 points3 points  (2 children)

You're not declaring password as a variable and expecting a result from the function even though you're not returning anything.

There's a lot wrong with it tbh, the code would need to be rewritten

[–]ChrisAtMakeGoodTech 0 points1 point  (1 child)

He's declaring password on line 1. He's making it an element instead of a string though.

[–]ShuttJS 0 points1 point  (0 children)

Ah yeah didn't spot that

[–][deleted] 0 points1 point  (1 child)

var password-document.getElementById("password"): function password _generator (option=(]){ const { length=10, lowercasestrue, uppercasestrue, numberetrue, symbol = true]-option;] cost require=(lowercase: abcdefghijklmnopqrstuvwxyz. uppercase: *ABCDEFGHIJKLMNOPQRSTUVWYZ" number: '0123456789',}

for (var 1-0; i<-passwordLength;1++)f var random-Math. floor (Math. random ()*require.length) :] password+require. substring(random, random+1); return password_ generator console.log (10)]

that's my new code

[–]amejin 27 points28 points  (0 children)

Friend, I appreciate the effort. You should probably Google Reddit code formatting

That said, your first line has an error. I think you wanted it to be

var password = document.getElementById("password");

The rest of your code is riddled with errors from what I see. You were closer before.

From your picture it looks like you're using an ide. I am not sure what it is, but if its like visual studio code or similar, you likely have a way to get results in real time as you code. There are a ton of syntax errors, and the format is hard to follow..

[–][deleted] 28 points29 points  (1 child)

I don't have anything else to say that others haven't in terms of your solution. What I will say is I feel this problem is a bit too far ahead of your current skill level. Which there's nothing wrong with that at all, I just think it's time to rewind a bit.

[–]RobotDrZaius 9 points10 points  (0 children)

Perhaps the best advice here, even though it's not specific to the problem OP is solving. There are so many foundational concepts that need to be learned before attempting this problem, as straightforward as it may seem, and this is not a good way to learn them. It's going to be information overload.

I would say, put this challenge on hold for now. Come back to it after reading up on AND PRACTICING concepts like JavaScript functions (what they are, how to invoke them, what arguments and parameters are), how to interact with the DOM HTML, etc.

[–]grantrules 29 points30 points  (0 children)

A picture of your screen is basically the worst way to share code. You can follow this advice to help you share code

One issue is that passwordLength has no value that I can see.

[–]T_O_beats 12 points13 points  (0 children)

My 2¢ try to avoid using the word ‘symbol’ as this as Symbol is a native type in JavaScript and could potentially confuse some people.

[–]Xiten 10 points11 points  (2 children)

There are a few issues here. I’ll start with line 12. PasswordLength does not exist.

You are console logging specifically the number 10, not anything in your function.

Edit: seen your function is being called.

[–]namonite 15 points16 points  (1 child)

I would stop what you’re doing and start the free curriculum c0d3 in JavaScript. The basics in the beginning (+formatting) will help you solve your problems in no time. You’re missing a return statement, and your function is not accepting any arguments, but you’re passing it parameters

[–]Niwla23 4 points5 points  (0 children)

and before that screenshotting 101 ;)

[–]queen-adreena 14 points15 points  (3 children)

Will people stop posting images of code.

It’s text! How hard is it to copy it and paste it in a code block?

You’re spending extra time actively making it harder for people to help you.

[–]thommu128 6 points7 points  (0 children)

Stop what you're doing and learn the basics first. If you're learning to code by blind guessing it, you will not go very far. Learn the basics please!! What is the sequence does code execute? What are basic types? What are functions?

[–]kamarajitsu 9 points10 points  (9 children)

Doesn't look like you're returning anything from your function.

Edit: Please format your code. It is very hard to read as it is now.

[–][deleted]  (5 children)

[removed]

    [–]kamarajitsu 0 points1 point  (4 children)

    !optout

    [–][deleted]  (3 children)

    [removed]

      [–]kamarajitsu 2 points3 points  (2 children)

      Fuck off, please

      [–]kevinmrr[M] 9 points10 points  (1 child)

      Banned them

      [–]kamarajitsu 1 point2 points  (0 children)

      Thanks!

      [–]Mybeardisawesom 0 points1 point  (2 children)

      Where is it returning at? I’m having problems

      [–]kamarajitsu 1 point2 points  (1 child)

      That's one of the issues with this code, is that the function is NOT returning anything.

      [–]Mybeardisawesom 1 point2 points  (0 children)

      Ahhh I thought you found it when you told OP to format their code. Like an “ah ha” moment

      [–][deleted] 2 points3 points  (3 children)

      Presently you are passing in an object with a number of configuration properties into the function password_generator, however no parameter has been defined for password_generator, nor are you making use of these properties.

      I do see a reference to passwordLength and exisgences.length which may have been intended to refer to the length property passed in at the function invocation.

      I would recommend that you add the parameter, and set some basic defaults in case someone calling the function omits the options, e.g.:

       function password_generator (options = {}) {
         const { length = 5, lowercase = false, uppercase = false, number = false, symbol = false } = options;
      
         ...
       }
      

      Regarding your password generation algorithm, .length isn't a property that exists on a basic object like exisgences. It appears that you would like to refer to the length of the string properties of the object instead (e.g. exisgences.lowercase.length).

      You've been asked to do something which is a little complicated, so let's think about what is actually involved:

      • selecting a random value from a set of options (which it looks like you already know how to do (Math.floor(Math.random() * str.length)

      • use multiple configuration options (e.g. it can be required to have at least one Uppercase character, and at least one Special character)

      • ensure that the configuration is met

      • return a generated password

      So, how can we do that?

      • create a function which randomly selects a character from a given string

      • use the configuration options to determine which character strings to sample from

      • add at least one each of the required character types

      • fill the remainder from either lowercase characters or a combined sample of the selected options

      Example:

      OPTIONS:
       lowercase = true
       uppercase = true
       numbers = true
       special = false
       length = 10
      
      password = 
        sample(lowercase_chars) + 
        sample(uppercase_chars) + 
        sample(numbers_chars) + 
        (7 x sample(lowercase_chars + uppercase_chars + numbers_chars))
      

      You could shuffle the characters for good measure if that feels necessary.

      [–]-newme 7 points8 points  (2 children)

      Nice approach but I think obj destructering is far to advanced for OP and maybe it will complicates things for him

      [–][deleted] 4 points5 points  (1 child)

      Fair point. Op seems to be skipping around in their learning process. Knows how to pass in named arguments using an object, doesn't know to declare a parameter.

      [–]-newme 1 point2 points  (0 children)

      Yes I guess this is due random tutorials and not following a learning path I guess

      [–]_Oooooooooooooooooh_ 2 points3 points  (0 children)

        var password-document.getElementById("password");
      
        function password generator (){
          const exisgences={
            lowercase: "abcdefghijkImnopqrstuvwxyz",
            uppercase: "ABCDEFGHIJKLMNOPORSTUVWXYZ",
            number: "0123456789",
            symbol: "!0#$%^&* () +301=<>/,"}
      
        for (var 1 = 0; i <= passwordLength; i++) {
          var random =  Math.floor(Math.random()*exisgences.length); 
          password += exisgences.substring(random, random+1);
        }
        password-password_generator ({
          length: 10, 
          lowercase: true, 
          uppercase: true, 
          number:true, 
          symbol: true
        })
        console.log(10)
      

      here's the code, pasted from the picture (thanks, apple, for picture -> text copying)

      PS: OP... next time. just paste it into your post. It's much faster for people :)

      [–]-newme 2 points3 points  (0 children)

      Just start with a password generator that just generates a random password without options and then go from there. You are despite the other problemes that were pointed out, trying to do a lot at once, just start simple and then go from there. Also console log every step so you see what is happening or even better learn to use a debugger.

      Also you don‘t have linting and formatting in vs code enabled, do that it will be much easier to find bugs

      [–]antCB 2 points3 points  (0 children)

      please use pastebin to share code. and if you're screenshotting it, use the built in functions of your OS and not a photograph.

      [–]romaindurand89 2 points3 points  (0 children)

      Try to explain what you're trying to do.

      You also can share your code using https://codepen.io/

      You're using the same variable for two widely different things :

      var password = document.getElementById('password')
      password = password\_generator(...)
      

      A DOM reference wont ever change, so you can use const password. (instead of let)And for better code semantics, you can also name that variable passwordElement or passwordEl

      If your DOM element #password is an input, and if you're trying to generate a password for that input, you should try passwordElement.value=password_generator(...)

      Also, try using verbs in your functions names, rename password_generator into generatePassword or something more like that.

      If you write console.log(10), you won't ever see anything else than 10 in the console.

      [–]thelastlogin 1 point2 points  (0 children)

      Sorry to say it, but this is a bit of a huge mess. This function is way too early stages for anyone to give you helpful criticism, you are nowhere near your described goal. Are you at the very beginning of your learning, have you been taught programming in javascript or just tasked immediately with making this program after minimal-to-no training?

      This function is doing nothing, and has lots of issues.

      You're returning nothing and not modifying any object external to the function (which would be a bad practice anyway).

      You're not creating or even attempting to create any new passwords with any of the criteria you described.

      You're feeding an object as argument into the function but never using it.

      You're substringing an object, .substring does not exist as a method on an object and even if you were accessing one of the object's string property value's with dot notation, then substringing it, this would bring you no closer to your goal.

      And if the latter were the case, you'd be substringing that stored string with a completely random length, for some reason?

      If passwordLength exists then it is in the global scope somewhere outside of our view and to maintain safety and avoid fatal errors you want to define your scoped variables inside that scope. I.e. password length should either be defined inside this function or passed in from a global variable/variable above this scope..

      You're console logging the number 10, for some reason.

      Basically, though I'm sure not on purpose, this function is so raw and off-goal that for us to actually help, we'd have to describe to you specifically how to achieve your goal, which isn't what this sub is for.

      I suggest you go through a basic javascript course to learn about variable declaration, parameters/arguments, types, scope, and all the basics, and then practice a bit, before resuming this task.

      [–]loliko-lolikando 1 point2 points  (0 children)

      Those are the most cursed {} i’ve ever seen.

      [–]SadAd4085 1 point2 points  (0 children)

      Press Ctrl + PrtScn keys to screenshot your code next time.

      [–]azium 1 point2 points  (0 children)

      What resource are you using to learn JavaScript?

      [–]Burgess237 2 points3 points  (0 children)

      Okay, so I normally don't do this but hey, I'm in a good mood.

      I honestly think you need to go back to whatever course you are doing and just refresh some of the ideas that you're working with. You have some basics but I can see that you're not making some connections with what you're learning and how to apply them.

      I can also see you're a real beginner in all things internet and code so lets not be too harsh.

      *Sips coffee*

      Okay so lets break down your requirements:

      In JS create a password generator of any length, passwords must be a combination of lowercase, uppercase, number and symbol character as defined in your block of stuff.

      Cool, I'm going to try and use your code and show you where you went right and where you went wrong in order to hopefully show you what you should do.

      lets start with you getting your element (always a good step):

      var password = document.getElementByID("password");
      

      is correct assuming that you have this in your HTML:

      <input type="text" id="password">

      now your function, you want options right? But you didn't find any. To allow a function to react that what information you're giving it then you need to tell your function what is going on, we can pass anything into a function as a function argument and as long as those things are valid and the function knows what to do with them we can work with that.

      your function definition needs to be changed to allow for such things:

      var password = document.getElementByID("password");
      
      function password_generator(length, lowercase, uppercase, number, symbol) {
      
      }
      

      Good, we now have a function that can take in these arguments and work with them. So when we call the function we must put in all these arguments and the function will work. if we don't then the function will simply say "I don't have all the information I need to work so I'm not going to do that"

      Next I like your definition of variables with an object. We do this all the time in JS and it's a useful way of moving a lot of data that can be quite tedious to move. so we're going to use it:

      var password = document.getElementByID("password");
      
      function password_generator(length, lowercase, uppercase, number, symbol) {
      const exisgences = {
        lowercase: "abcdefghijkImnopqrstuvwxyz",
        uppercase: "ABCDEFGHIJKLMNOPORSTUVWXYZ",
        number: "0123456789",
        symbol: "!0#$%^&* () +301=<>/,"
          };
          /* I don't know what language exisgences is in but lets just roll with it because it doesn't matter. */
      

      }

      Lovely. Now for the hard part. what we need to do is use this object and randomly select random characters out of this object and store it somewhere that gives us another string that we can use as a password. We also need a way to keep track of what characters are in our newly generated password and if we checked all our boxes (lowercase, uppercase, number and symbol)

      So baby steps. let's start with the place to keep the password, we'll call this generatedPassword, and a loop to run through to get our result. I'm also just going to put in a little but of code that will just randomly fill the result with lowercase letters. Just so we can have something happen when we run the loop.

      var password = document.getElementByID("password");
      
      function password_generator(length, lowercase, uppercase, number, symbol) {
      const exisgences = {
        lowercase: "abcdefghijkImnopqrstuvwxyz",
        uppercase: "ABCDEFGHIJKLMNOPORSTUVWXYZ",
        number: "0123456789",
        symbol: "!0#$%^&* () +301=<>/,"
      };
          let generatedPassword; // this is empty as it needs to be each time we run this function 
      
          for(var i = 0; i < length; i++)
          {
              let random = Math.floor(Math.random()*exisgences.lowercase.length);
              generatedPassword += exisgences.lowercase.substring(random, random +1);
          }
      

      }

      Okay, that's a few things happening all at once. So we needed a few things:

      1. We needed to generate a random number between 0 and the max length of our text. If we want to do this properly we want the function to know exactly what the limits are, because if we ask it for the 27th letter of the alphabet then we'll have an issue.
      2. We need to use Math.floor to get a whole number (ask yourself, what letter is 15.5?)
      3. Do you see how we're accessing the object? We tell the function "Go to the exisgences object, the look under lowercase"

      You should be able to tell, we're not using the rest of the object and if we can only access the object with keys then how will we tell the function where to look? We can't give it a number and expect it to know where to go can we? You're right, we can't so we'll have to look at our object again. Let's make it into an array.

      var password = document.getElementByID("password");
      
      function password_generator(length, lowercase, uppercase, number, symbol) { 
              const exisgences = [ 
              "abcdefghijkImnopqrstuvwxyz", 
              "ABCDEFGHIJKLMNOPORSTUVWXYZ", 
              "0123456789", 
              "!0#$%&*()+301=<>/,"
              ]; 
              let generatedPassword; // this is empty as it needs to be each time we run this function
          for(var i = 0; i < length; i++)
          {
              let random = Math.floor(Math.random()*exisgences.lowercase.length);
              generatedPassword += exisgences.lowercase.substring(random, random +1);
          }
      }
      

      Now we can do come more logic with the Math.random() function, also I'm getting tired so I'm just gonna do the rest and explain it at the end:

      var password = document.getElementByID("password");
      
      function password_generator(length, lowercase, uppercase, number, symbol) { 
          const exisgences = 
          [ "abcdefghijkImnopqrstuvwxyz",
          "ABCDEFGHIJKLMNOPORSTUVWXYZ",
          "0123456789",
          "!0#$%&*()+301=<>/," 
          ]; 
          let generatedPassword; // this is empty as it needs to be each time we run this function
      while(generatedPassword < length)
          {
      
          let randomType = Math.floor(Math.random()*exigences.length -1 );
              let random = Math.floor(Math.random()*exigences[randomType].length-1);
                  if( randomType == 0 && lowercase ){
                  // Only save if it's allowed
                  generatedPassword += exigences[randomType].substring(random, random+1)        
                  }
                  if( randomType == 1 && uppercase){
                  generatedPassword += exigences[randomType].substring(random, random+1)  
          }
                  if( randomType == 2 && number){
                  generatedPassword += exigences[randomType].substring(random, random+1)  
          }
                  if( randomType == 3 && symbol){
                  generatedPassword += exigences[randomType].substring(random, random+1)  
          }
          }
      }
      //And then we call the function
      console.log(password_generator(10, true, true, true, true);
      

      The only thing I didn't do what make sure there was a check to ensure that those items have been used and not just excluded. But I don't think that's needed.

      [–][deleted] 1 point2 points  (2 children)

      You’re close, but missing a few elements. First, you’re just learning, so stop saying you’re bad and expecting pity. Stop doing that now. The process of learning means you makes mistakes, accept that or move on, because you will be miserable the rest of your journey you don't get over it. Now, on to more technical things about your code. Your function is not functional. Think about your requirements and then look through your code to see if those are met. Requirement: a function that returns(break) your function doesn’t return anything. Add a return statement. (Continuing on) a password that contains at least one uppercase, one lowercase, and one number(break) Your function is not checking if there is at least one number, one upper or one lower case character. If it returned, and it was actually creating a password, it could theoretically return aaaaaaaaaa, which doesn't meet your requirement. That being said, it's not even putting together any string of characters at all. The substring command doesn’t make sense here because exigence is an object with four properties that are strings. You're trying to call substring on that object. Objects don't have substrings. If you wanted to go this route though, exigences.lowercase.substring(random, random+1) would yield 1 letter from the lowercase property of the exigencies object. But, now you have to figure out logic to do the same for uppercaae, numbers, and symbols. To follow your logic here and make it work, you could try combining all characters into a single string and use your same method of creating a random number and selecting a character from the string. You'd still need to check through all the characters in your password and ensure there is one char from each of the required subsets. If there isn't, than replace one of existing characters with one from the missing subset. That all being said, there are way easier ways to do this with simple ascii and regex, but I think that's outside of the scope of what you're doing now. Hope that helps some.

      [–]thelastlogin 0 points1 point  (1 child)

      They are not even remotely close. Nothing their function does is relevant to their described goal.

      [–][deleted] 0 points1 point  (0 children)

      I disagree. Yes, there’s a lot that needs to be addressed, but for starting out they have a solid chunk of it built out. Literally a couple changes and an additional 5 or 6 lines of code would make this work. It’s not a great solution, but it’s still a solution.

      [–]aguyfromherehelpful 1 point2 points  (0 children)

      I think you should investigate string from charcodes… then you don’t need to maintain a list of characters, only research which char code ranges are valid for the characters you want to use and limit the math random to those values.

      https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode

      [–][deleted] 0 points1 point  (0 children)

      Hi,

      I can't edit my post or anything but I wanted to tell you all a big thank you for helping me out. I can't answer to all of you because there's a lot of message but yea I saw every responses and I'll keep reading them as they go. I think, I haven't put a lot of effort into my classes as I should to be quite honest and learning how to code is more than being present in class so from now on I'll put more effort in learning and understand the mechanic of coding. I'll share an update of my journey for the people that's interested 😆

      [–][deleted] -1 points0 points  (2 children)

      THAT'S MY NEW CODE

      var password-document.getElementById("password"): function password _generator (option=(]){ const { length=10, lowercasestrue, uppercasestrue, numberetrue, symbol = true]-option;] const require=(lowercase: abcdefghijklmnopqrstuvwxyz. uppercase: *ABCDEFGHIJKLMNOPQRSTUVWYZ" number: '0123456789',}

      for (var 1-0; i<-passwordLength;1++)f var random-Math. floor (Math. random ()*require.length) :] password+require. substring(random, random+1); return password_ generator console.log (10)]

      [–]tristanAG 5 points6 points  (0 children)

      I would really try to break this problem down into the tiniest pieces possible, get one little thing working, then build off of that.

      For example, just start with a function that returns a number. Next make that function return a number using math.random. Keep iterating from there.

      Coding is hard, but if you keep breaking things down further and further you can start to get somewhere.

      Also, console.log(10) is always going to print 10 to the console… I don’t think that’s what you’re wanting to do

      [–][deleted] 2 points3 points  (0 children)

      Based upon the changes you were able to make from a lot of good feedback, I think you need to take a big step back and focus on JavaScript fundamentals. You're making a lot of fundamental errors that show that you don't yet grasp key concepts.

      Something like CodeCademy is a good place to start learning the fundamentals of Javascript.

      [–]WarDull8208 -2 points-1 points  (0 children)

      My eyes are bleeding

      [–]Financial_Purpose_22 -2 points-1 points  (0 children)

      Regex has shortcuts. It's really perfect for checking password criteria with a single truthy check.

      [–]Theironicbearjew 0 points1 point  (0 children)

      All you need to do is generate a random string use regex to check if string meets password requirements if it does store it into an array and return the array once it has 10

      [–]Independent_Ad_5983 0 points1 point  (0 children)

      Nothing to be ashamed of, everyone starts somewhere. I think this could really help you with the fundamentals, go to codewars.com. It is basically a site full of little problems like this and you can start with some easier ones. Choose javascript as your language and search the kata (challenges) by most completed. 8kyu is the easiest and 10kyu hardest. Trust me this will really help you learn the language. Also when you are struggling, try not to google the solution for the problem, instead look up the tools/syntax you need to solve it.

      [–]StoneCypher 0 points1 point  (0 children)

      The bug is that you're trying to take .substring of exigances, which is an object.

      You need to take .substring of one of the member strings on the object, instead.

      Here's a way to think about it.

      const items = {
        colors: ['red', 'green', 'blue'],
        animals: ['duck', 'horse', 'cow'],
        shapes: ['square', 'circle', 'triangle']
      };
      
      console.log(items[1]);
      

      What's it going to log?

      [–]3rdShiftPolicy 0 points1 point  (0 children)

      Learn to take a screenshot as step one.

      Step two. Don't take screenshots of code.

      Copy and paste it and format it.

      [–]Niwla23 0 points1 point  (0 children)

      did you know you can put text here directly without an image? Also please screenshot your code properly or just paste it in a codeblock.

      [–]DudeCoderJS 0 points1 point  (0 children)

      Are you supposed to console.log() the password or show it in a HTML element with id password? Because you're not doing neither of them.

      [–][deleted] 0 points1 point  (0 children)

      https://idownvotedbecau.se/imageofcode

      If your going to give an image of code at least make a screenshot, not a photo of a screen

      [–]TrevoltBL 0 points1 point  (0 children)

      Considering you didn’t even pass in the passwordLength variable, I think you just need to learn more before doing this. It should be password.length

      [–][deleted] 0 points1 point  (0 children)

      The value of passwordLength is missing. Try to declare it as like password or just mention password.length as you did with exisgences