Podcast Lookup

React.js Practical Challenge Project – Test Your Skills and Build Real-World Applications

ReactJS Developers Podcast

  • December 3, 2026
  • 58 min
  • Episode 13
Episode page
About this episodeIn this episode, we take on a React.js Challenge Project designed to put your frontend development knowledge into practice.Learning React…
In this episode, we take on a React.js Challenge Project designed to put your frontend development knowledge into practice.Learning React involves more than understanding components, Hooks, props, and state management. The real challenge is combining these concepts to build functional, interactive, and maintainable applications.Through this practical coding challenge, you'll have the opportunity to apply your React knowledge, improve your problem-solving abilities, and understand how different React concepts work together in a real development environment.Whether you're preparing for a frontend developer role, building your portfolio, or improving your React skills, this episode encourages you to move from theoretical learning to practical development.What You'll Learn
  • Applying React fundamentals in a practical project.

  • Structuring a React application.

  • Creating reusable functional components.

  • Managing component state with Hooks.

  • Passing data using props.

  • Handling user interactions and events.

  • Implementing conditional rendering.

  • Working with forms and user input.

  • Managing application data.

  • Debugging common React errors.

  • Improving component organisation and code readability.

  • Developing problem-solving skills through practical coding.

Who Should Watch?
  • Beginner and intermediate React developers.

  • JavaScript and frontend development students.

  • Developers preparing for technical interviews.

  • Software engineering students.

  • Anyone building a React developer portfolio.

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

React.js Practical Challenge Project – Test Your Skills and Build Real-World Applications

00:00—
  1. Speaker 1

    Now, I am giving you a simple project challenge which will help you to practice well and all the concepts you have studied in previous lectures will be revised. So, our project is something like this. You have to make a password generator Password generator means you can generate a password definitely. But there are some things that you have to keep in mind. First of all, you have to keep in mind the length. As the length changes, your password should change accordingly. We are getting a random password generated. As the length changes, your password should change accordingly. If I click on Number Allowed, then a number should also appear here. Randomly, any number can come. If I click on Character Allowed, then a character should also be added. So, in this way, you have to generate a password. Along with that, you should have an option of Reset Password, where you click on Reset Password, then the password will be reset again, i.e. 8 length. We have given the initial value of 8 length password. So, 8 length password should not be allowed. By default, it should not be allowed. Rest, you can change here. You can allow number, character. And along with that, you have to make one more additional feature of save password. Whatever password you have made, as soon as you click on save password, this exact same password should be saved. So, as soon as I said save password, you can see that the password is saved. Suppose I increased the password a little more, I did not allow the character, only the number is allowed. I said save password, this password is saved. See, you will not get even one character here. Suppose I did not allow the number, I just made a small cute password. And here I said save password, here your password has been saved. So save password, reset password, and all these functionalities, your logic will improve a lot in this. And along with that, copy password, from where you can use reference, which you have studied till now. In previous lectures, I have focused more on this, that till now we have studied form handling properly, form handling here, the idea will be revised, all the controlled components will be revised. Then the reference we have studied, use ref hook, will be revised here and use state, use effect will be revised here. So, as soon as I am doing copy password, then you have to do the work of copying the password, you have to You can take reference of what we can do in react if we want to copy the password in clipboard. So you can take reference of this. On copying, you should select this. To select, I will give you hints here. Use reference will be used here. You will be selecting it by taking reference of this input field. You will be doing sort of DOM manipulation. So, as soon as I write any password here, I do it in copy password, it has been selected and actually it has been copied. If I come here and paste it, then see our password is coming here. So, you have to make the copy password functionality. Along with that, it should be selected. And all these things you have to do. Reset password should be done here. And click on save password, it should be saved. Okay, you can show one more thing here. As we can't see length here. So, you can also show the length of our project. Can you see it hovering here? No, you can't. So, you can show the length here. I have given you an additional task. And if you want, you can also show the length here with the password. And you can show all the details related to it. So, it's a small project. The logic will improve a lot if you make it yourself. First, you have to try it yourself. How will you generate the password first? And you will make a copy-paste. And if it doesn't work, then definitely, why is this video so long? Because I have told you everything. So first try it yourself. And then if it doesn't work, then definitely it can't work. It's not a big deal. You are still a beginner. So now you have to walk with your hands. You have to practice some projects with your hands. Then you will slowly come to your level that yes, now I can make it. Okay. So, You have to do this much. This is a simple task, a simple project, which you should try first yourself. And if it doesn't work, then come quickly. Okay? So quickly open your React folder wherever you are working. I am working in this folder, so I have already opened the React folder in VS Code. So after that, what we have to do is first of all, we have to install Vite and set up Tailwind. So come here on Chrome and directly search here Tailwind CSS. You have already known all this. We have been doing all this for a long time. So here you have to copy paste. They have given Vite only. Using Vite, you can set up Tailwind. So Vite will be installed. Tailwind will also be set up. So copy from here. And after copying, you have to come here and paste. Like this. And here, what name do you want to give? So I give the name project here and here also let it be project instead of my project. Ok, let's enter. So it is doing its task. Here you have to select react. Come down a little and select react. Then you have to select javascript here. You have to do no and then you have to install npm and start. No, don't start now. Our proper setup has not been done yet. So this is done and we have come inside the project folder, see carefully whether it is inside the project folder or not. So now we have created our project here through Vite and here it is inside the project folder. So what else do we have to do inside this? So we have to install Tailwind. So I am telling all this in speed because I know you know all these things. You are following the whole playlist from the beginning. So, let it install here. Until then, let's do the next work. Here, you have to copy it all in this way. Go to vid.config.ts and paste it. So, project. After that, vid.config.js. And here, we are not using TypeScript. That's why here it is js. Otherwise, it would be ts. So, we have imported it. And after importing, you have to apply it in this way. Now our tailwind is applied. Now import it in css file. This is not a big problem. This index.css is our main file of css. So we will remove it from here and paste it here. Then remove all the things from app.css also. Let's write our boilerplate code like this. body, html. Here we give BG color, a little black and give color white. So that your eyes don't get spoiled. So something like this will be visible here. I will run and show NPM run dev. So our tailwind and everything has been set up properly. Something you can see like this here. So I close this. So far our proper has been done. CSS and everything we have done. Basically tailwind we have set up properly. We have also run. All right. Now let's do a little more setup here. Let's take the color like this. It looks better. And the background color is like this. And what color should we take? So do this in white only. So okay, it looks better. Now what we have to do is cut everything. And once quickly check if Tailwind is working or not. So here I do all this cut. And hide it here. I will zoom it so that you can see it clearly. And I will close it for the time being. Alright. So here you can remove this. We don't need it now. Let's clean it up completely. We don't need this either. And here in main.jsx remove strict mode for the time being. So that we can console. So that we don't see things twice. Otherwise you will get confused. Rest you should do in strict mode in development. If you are doing development. But for the time being you don't have confusion. So I removed it. Okay. You can see things twice. You won't see them in the console. So, first of all, let's check if your Tailwind is working or not. Hello. Hi. And here we give the class name. BG Red 500. So, it should work according to me. See, it's working. It's a proper Tailwind. But we are not getting suggestions. We will have to see why we are not getting suggestions. All things are configured. Let's reload control shift p once and see. After reloading many times, suggestions are available. So here. And from the starting you are seeing what things you have to do for these suggestions. Here you have to come in extension in this way. And here I have installed Tailwind IntelliSense. You have to do all this. This is Tailwind CSS IntelliSense. So until you do all this, you will not be able to get suggestions. Or the way I am working, you will not be able to do it that way. So, if you configure everything properly, then only you will be able to make the project properly. So, that's why I say again and again, follow from the beginning. So, here we have our BG500. You must be getting suggestions right now. See, we are getting suggestions. Very good. And here we are doing our proper work in this way. So, what do we have to do now? We have to make a password generator. So, let's start the work. Let H1 be here. I will write here password generator and I repeat it again. We will not focus too much on CSS now. We will just decorate it a little bit so that it looks good. We don't have to work too much on it. So let's center the text and let's give 5 from the margin top. So something like this will be visible. And let's make the font a little bold. Okay. Something like this is coming up for now. What else can we do? So, what other things do we need? Think about that first. What other things do we need? So, first of all, we definitely need a password. So, we will make a password state here. Password, set password. Right? Let me select it in pen. So, a password state will be made. Okay. Which states will be made? Let's decide that first. So, a password state will be made. We are also checking whether there should be a number in it or not. So, definitely, a number state will be created. Number. Then, we are checking whether there should be a character or not. We are making a checkbox, basically. So, a character state will be created. What other things are we doing? Think more. and basically length is there, length we are doing more and less, that how much length password should be, then a length state will be made, what else can happen, so for now, let's take so much that there should be a password state, where we will store the password, what should come in the number, true or false should come, if you tick, then the number will be true, that means we have to show the number in the password, And if you untick it again, it should be false. That means we don't have to show the number. So true or false, you will get the boolean value in this. Okay. Then you will definitely get the boolean value in the character as well. You have to show it or not. There are only two possibilities. Then in the length, you will definitely get the length. In this, you can see, from where to where you want to take. By default, we will give length 8. And after that, we can increase or decrease. Between 0 to 100. Then length will come. There will be some more things. So, we will see later. First, we have to make this small state. So, here we come quickly. And const password, set password is equal to useState. And in this way, by default, empty value will be here. Alright. Very good. And here our password is capitalized. I don't know how to write it. We had to write it in small. Okay. Password is done. After that, we get length const length comma set length equal to use stage. And in length, by default, we give 8 for now. Then what will come after that? After that, we will get number should be or not. Is number number number allowed comma set isNumberAllowed useState and here by default it will remain false then we will get isCharacterAllowed characterAllowed comma set isCharacterAllowed useState here also we will get false So, that's it. Now, what we have to do? First of all, make an input box here where the password will be visible. Let's make some things. As it comes to mind, let's make it so that we can see it together and create logic. It's a small project, so there's not much flow. You don't have to go in flow. After this, you have to do this. It's a very small project. You must be knowing it. You have to make a text field where the password will be visible. You have to make a button, a copy one. After that, you have to make some other input fields where you You can tick on the checkbox or not. And then you have to make the range. So if you want to make things like this, then let's quickly make it. What's the problem? So input, type text, and let's go a little further. It will look good. Here our placeholder will be done. Password and what else to give here, you think. And we don't want to make it editable, so let's make our read only true here. So, we won't be able to type anything on it. So, for now, let's come here and see. So, something like this is visible to us. Let's design it a little. Class name. Here, outline. Outline will be none. And then border. Border will also be none. And BG. BG gray will be given. BG gray 400. How will it look? Let's see. Padding X will be given. Padding Y will be given. Padding Y will be given. Padding Y will be given. And what we can do is give a little bit of rounded. We will only give rounded in the left. No, we will give it completely. Rounded. Because we can do the button on this side too. No, we will do it completely. There is no need to style it so much. We will make rounded large here. Rounded large. So, something like this is looking. Which is looking very bad. BG 200 only here. So now it's fine. We can't see the inside. So for that we have to do text black. We will do text black. So now we can see that our password is going to come here. Alright. And write the password like this. Is it looking better? It's looking better. Let's do one thing. Let's make a div here. And we will make it a flexbox so that everything comes in the center. So class name flex. Flex direction will be flex column. Okay. Like this. And we will give gap of 5. Alright. And here maximum width. Maximum width 60rem. So let's see how it looks. And it is actually zoomed a little. Otherwise it looks like this. So let's give 40rem here. 40. So, this is something like this. Wait a minute. What is this? Hmm. Where were we? Here. So, give 30rem. It will look better. Maximum width 30rem. And why is this showing like this? So, nothing much. It is basically suggesting that we can write maximum width 120 for 30rem. No issue. You can write that too. So, for now, it is looking something like this. I will zoom it a little. and let's do one more thing here, let's do margin auto, then it will come to the center in this way, ok, it looks perfect, password generator, our password will be visible here, below it, we will have to make another button in this way, button copy password, copy password, and here we will give the style of the button, we will give it, we will copy it below for the reset button, so let's quickly give the style, bg blue 500, and padding x, say 3, padding y, say 1, rounded large, so let's see, how is it looking, it looks like this, padding x, actually, there is no need to give, right, or let it be, when you will be responsive, it will be useful, padding y, say 2, sorry, so copy password, is done, and in the same way, here will come, reset password, one will come here reset password ok reset password and below that one will come save password just here will come save password so these are our three buttons now after that here we have to give a range option so here we give just below it so input type range, and define the maximum and minimum. I will give 0 as minimum and 100 as maximum. The maximum length will be 100 and the minimum length will be 0. Let's link the value. The value will be length. The length we have defined here is 8. And whatever changes will happen here, we have attached that length here. We have basically made a controlled component. In the previous lectures, we have learned how to handle the checkbox in a controlled way. In this way, input boxes of different types, text, checkbox, radio button, select, drop-down have been done. So we have learned properly. If you haven't seen it, then you must be thinking that I am going a little fast, I am not getting this proper explanation. But I have told you all that. Here, from the point of view of the project, I am telling you all the things. So, here the minimum value has come, it should be this much, maximum should be this much. We have given the length. Until we did not give the length, until we did not give the length, we could have done it back and forth. But because to make it controlled, we linked it with the state, so now the length is fixed here, you cannot do it back and forth until you put on change. so here put onChangeHandler also onChange and E you will get its value from E.target.value whenever you will change if you will do 9 then you will get 9 value if you will take it to 10 then you will get 10 so what you have to do is set in length set length E.target.value Target.Value. All right. So whatever value you are getting here will be set in length. And after setting in length, whatever length will come here, we have set it in value here. Whenever we will move length will be set and that length will be reflected here. So now you come here and see. So this length is working properly. And here if you want to come and see in console that length is actually changing or not. So you can see length by doing CLG. So here you can see our length is changing properly. So our length is done, our copy password is done, reset password, save password. Now here the number will be allowed or not, then the characters will be there or not, we have to make all these things, so let's make that too quickly. So I give it here, right? At this place. Here just below the input, here we have to make another input, type will just be your checkbox here. What other changes will happen here? So checkbox is done, here we have to give the label too. so that you can see what you have to select here. So, I will do one thing in the label. I will give a label here. Number allowed. Number allowed. Okay, like this. So if you want to keep the number allowed, nothing is happening till now. If I click here, then it will work, but nothing is happening here because we have not linked the label with the input. So what do we do to link the label with the input? Here we give the same value in HTML4 and ID. So here you can give the same value in anything. I give here number allowed. Number allowed. I give the same value here. This will be linked again. See, if I click on it, then it is working properly. We have seen all this before. Sorry. So, here you have this. It is linked properly. Type is our checkbox. Alright. What other things we have to do here? What value do we have to give here? Tell me quickly. Value we have to give isNumberAllowed which we had made state isNumberAllowed. Now, we have given isNumberAllowed. So, by default, it will be false. See, this is false. If we tick, then true is also happening, but true is not getting set here. True is not getting set here. So, what will we have to do to set? Where did it go? This one, right? So, what will we have to do to set? You can see here, is number allowed changing or not? Is number allowed? So, here, is number allowed, what was it earlier? It was false. We ticked, two changes did not happen. Here, false is false. Okay? So we have to handle it properly. Because we want to make a controlled checkbox here. So here we have passed the value. Put onChangeHandler. Here also in the same way, what will you do? e.target.value. Set isNumberAllowed in e.target.value. Is this right? e.target.value. Is it right in this case? Quickly comment and tell us. Two lectures, just two lectures I have told you earlier. Is e.target.value here correct? Do we have to write e.target.value here? Not at all. Here, E.target.value is not there. Here, you have to do E.target.checked. You will get on and off with value. You will get true and false in Boolean only if you do checked. So, you have to do E.target.checked. Now, if you click here, then see, you have true. Again, if you click here, then it will be false. Then, you will click, it will be true. Then, you will click, it will be false. Now, this is your proper link with state. And you are also changing here. So, it is reflecting in state. And again, it is set here. So, this is our controlled checkbox. One. We will replicate this. And we will make it for character allowed. Character allowed. Okay. Character allowed. Here also character allowed. Checkbox will remain. And here is character allowed will come in value. Is character allowed. It is very easy. It is not very complicated here. Okay. Is character allowed. And here set is character allowed. Ori.target.checked. And here character allowed. Very good. This is how it is coming here. Number allowed. Character allowed is also true. Alright. So, We have made almost everything. Number allowed, character allowed, copy password, reset password, and save password. And here we have also given the length. Now how will we generate the password? This is our main topic. Here our main logic will be that how will the password be generated? If we click on the number, then the number should also be added to it. And then if we are clicking on the character, then the character should also be added. If we are doing more or less length, then the password should be generated accordingly. So how will we do this? It is very easy. Here you will get almost all the ideas that I told you. Here you are getting the idea of state. Here you will get the idea of useEffect. And then here useRef which I discussed in the previous lecture is also going to be useful here. So let's quickly see how to make it. So first of all we will make a function. Const generatePassword and according to me, you can make logic by yourself. How will the password be generated? You can make its logic. Basically, what do you need in the password? You need characters from small a, b, c, d to z and capital a, b, c, d to z. You need alphabets, all of them. So, you make a string here where all the alphabets will be. Const string is equal to A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. Did I write ABCD correctly? You can see. A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. So, according to me, all the alphabets have come here. In small b and capital B too. Now from here we have to generate, basically we have to pick one character, so how will we do that? So understand my point carefully here. So this is the string, okay. Now in this string, it is possible that there is no number here, there is no character. It is possible that I also need a number. So if, if isNumberAllowed will be true, here we have made a state, isNumberAllowed. So whenever we will do true from here, where is numberAllowed? Whenever we will click on checkbox, numberAllowed will be true. So if it will be true, then we will add number in this string also. htr plus equal to, plus equal to means, htr is equal to htr plus, okay, these are all basic things, htr plus equal to, here we will add number also, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, alright, number added, then similarly, if, if our character allowed also, character allowed, then you see, what other things you want to add in character, plus equal to, see, if number allowed, then number will also be added in same string, and if character allowed, then character also we will add in same string, ok so if character is allowed and how to cut I will tell you all how to generate and how to pick random numbers I will tell you all so here htr plus equal to you can see which characters you want to take so suppose I want to take exclamation mark I want to take this I have to write like this I want to take this here I want to take this too this this this and then Then this. So, I want to take so many things here. Okay. If you want more, then you can see the character. What all characters you want to keep in special character. I want to keep so many things. Alright. So, if character is allowed, then you will see so many things here. Okay. Now, what to do? Now, here. Now, here. Definitely, you have. String is ready. This is the string. And you have to cut out the password from this. But how will we cut? Will we cut this much from the middle? Or will we cut this much from the middle? And more things will be added to this. 1, 2, 3, 4, 5, 6, 7, 8, 9. So we will cut that part. How will we do it? So we have to cut randomly. It's not like we have to cut this much part from the middle. Or we have to cut this much part. Randomly we have to pick one by one. Sometimes we have picked L. Sometimes we have picked F. Then if the number is allowed, then we have picked 3. And then we have picked at the rate. In this way, randomly, if there is 8 length, then we have to pick 8 times. If it's 9 length, then pick 9 times. If it's 10 length, then pick 10 times. Okay? Can you understand what I'm saying? I'm saying that it's very easy. Look, we've made a string here. htr is equal to. Here, you're getting a lot of things. a, b, c, d. Then, some numbers are also coming. 0, 1, 2, 3, 4, 5, 6, till 9. And then, some characters are also coming like this. Isn't it? So, I want to say that here, it is not like picking 5 lengths of IBCD at once. This kind of password does not exist. Anything random happens, right? So, we have to randomly choose from here. Suppose, our length is Length is 5. So, we have to remove the character from here 5 times. Suppose, I removed B for the first time. Then, I randomly picked 1 for the second time. Then, I randomly picked 4 for the third time. Then, I randomly picked this tilde for the fourth time. Then, I randomly picked D for the fifth time. So, our password became B14 tilde and D. This became our password. So, how will we do this? So, you know this much. Think first. You know this much that we have to do the same thing 5 times to pick. That means, first of all, you should know that we will run a loop which will run 5 times. It will run till length. If length is 5, then it will run 5 times. If length is 6, then it will run 6 times. We have to run a loop first. So, come here and let's run a loop quickly. So, for, one minute, for let i is equal to 1 say i less than equal to, i less than equal to, if you are running from 1, then less than equal to, and if you are running from 0, then less than. So, these are all basic things that you know. Less than equal to, length you have to run, i plus plus. So, this loop is running. Now, what to do after running the loop? Do you know that string works on the basis of index? 0, 1, 2, 3, 4. If our string is written here, M, A, N, A, S, then its index will be 0, 1, 2, 3, 4. If I want to take the value of the second index, then N will come. If I want to take the value of the third index, then A will come. So we have to pick it up in the same way. Pick it up on the basis of index. Now pick it up randomly. So definitely we should have a random index. and random index, i.e. random number, random number, i.e. random number, we have to generate. So, how to generate random number? I have explained all this in detail, in a very detailed way in JavaScript. After seeing that, I don't think you will ever forget that concept. So, go and see it once. I will tell you here. Math dot, I will tell you a little. Math dot random, you have a method. Whenever you call math dot random, then from 0 to 1, It gives you the value between 1, where 0 is included and 1 is not included. You must have read all this in math. This range denotes that 0 is included and this denotes that 1 is not included. That means you can get 0, 0.1, 0.12, 0.9, but 1 will never come. So this is its range. If you call mat.random, then what do we want? In string, we have a, b, c, d, e. So which index do we want? We want 0, 1, 2, 3, 4. We don't want 5 or less than 0. We want a number from 0 to 4. So there is a very short way for this. There is a proper way here. See the range. If your range is 0 to 1, you need 10. Just an example. You need 10. So, you will do x10 here. You will do x10 here. So, you will do x10 here. So, you will do x10 here. So, you will do x10 here. So, you will do x10 here. So, now the range has shifted from 0 to 9. 10 will never be there. 9.9 can be there. 10 will never be there. 0 can be there. So, it has shifted from 0 to 9.9. Okay. From 0 to 9.9. If we add math.floor, then definitely here, if we add math.floor, then definitely it will convert to integer value. If it is 9.9, then it will convert to 9. Okay. From math.floor, the lower integer value is coming to you. You can put it on the number line and see. So here after mat.floor, your range has come from 0 to 9. Something like this. So in the same way, we will work on the index basis as well. How? So as I did tan, then the range went from 0 to 10. If I do 8 here, then the range will be from 0 to 8. If I do 9 here, then the range will be from 0 to 9. Do you understand what I mean? So how much index do I need? You think and tell yourself, how much index do I need? I don't want to fix the range to 10 or 9. It will depend on the string. If the length of the string is 9, then we will multiply it by 9. into 9. Now, it won't be possible to write. We will do into 9. If the length of this string is 9, then we will do into 9. So, our range will come from 0 to 9. Okay. And definitely, it will go from 0 to 9. If the length is 9, then the index will start from 0 and it will go to 8. It will go to 8. And here, definitely, we will do mat.floor. So, our range will come from 9 to 8. Once you do it yourself like this, and if you don't understand, there is a little bit of confusion left, then definitely you can go and do the whole thing in Javascript, that video, you will enjoy it. Okay, where I have told you all the work related to math.random, etc. All right. So what will we do here? Let random index first generate, random index is equal to math.random and here into htr.length will do. If our length is 5, then from 0 to 5 will be there, where 5 is not included. That means, it will go till 4. Okay? And we need till 4. Because index will start from 0 and goes till less than length. You know this. Now, here this point value will be coming. So, we have to convert it into integer. So, we will do mat.floor. We will do floor because we need the lower value. That means, if 4.9 is there, then we need 4, not 5. Okay? So, this is our random index. Now, if you want, then here, you can see console.log random index and I also call generate password in useEffect if I call in useEffect then you know it will call only once generate password whenever I reload it will call only once because I will not give anything in dependency array so it will call only once whenever I reload so let's see what is being generated here I reload So, here, how many times is this loop running? It is running 8 times, right? I run the loop once here. I give length 1, so how many times will this loop run? It will run only once. So, I reload. So, here we have consoled more things. Remove all this, otherwise there will be confusion here. So, come here and see. I reload, here 39 has been generated. I reload, here 49 has been generated. I reload, here 44 has been generated. I reload, here 23 has been generated. Like this, because right now, here, some error is being generated. No, no, it's fine, it's fine. You can calculate its length and see. If you are a little confused, then I will take 8 here and show you. I took 8, that means, from 0 to 7. From 0 to 7, 8 will never come. So now let's see. I reload. 2 came. Then I reloaded. 1 came. Then I reloaded. 3 came. 2 came. 7 came. 5 came. 0 came. 8 will never come. It will come less than 8. Okay. So it is working like this. So I gave string.length. htr.length. So it will generate one less than that. So we got the index. That means from 0 to here we got. And if the number also comes here, then it is added. And if the character is also added, then it is added. So, we are getting random index. If we run the loop 10 times, then we will get 10 times random index and we will be able to pick the character 10 times. Okay? Very good. This is what we wanted. This is what we wanted. If we want to make a password of 8 length, then we have to pick it 8 times. So, let's pick it. Let character picked is equal to htr.careat, you must have read all this, that if you want to find a character from a string, on a given index, then we use careat, so put index here, random index, whatever index will be generated, from there it will find a character, by finding a character, the character will come in the field, but a single character has come, now, while joining each character, we have to make a password, so how will we make that, so to make that, let, not let, actually, we have made some password, variable, not made, so const password, or only pass will be written like this. Pass will be empty in the starting. Pass means password. And here, password plus equal to, again the same, password is equal to password plus, we will keep adding in the old password. What will we keep adding? Character pick. Whatever character we are picking, we will keep adding in it. So, if 8 loops will run, then 8 characters will be added in it. If 9 loops will run, then 9 characters will be added. Now, let's see here, what has our password generated. So, we definitely have to see outside the loop. Password. Okay. So, let's reload. So, there is some problem here. str.length is not a function. I am so sorry. I am so sorry. str.length. I had to do it this way. Let's reload. And wait, wait, wait. Somewhere we have used constant. Okay, here we have used const. We cannot assign again in constant variable. Then we have to let in string also. Alright. Now it is fine. So, here see our password is generating. See this. Can you see? Password is generating. See this. Now there is no type of number here. If I allow the number here, then the number will not be visible here. If I reload, then it will come back because it will refresh here and everything will be clean and reset again. False, false, so the number will not be visible. So I will show you that too right now. For now, the password is being generated where there is no number. Now what we have to do? Now what to do? Think carefully. The function of generatePassword has been created. Now when to call the function? When to call the function? Listen to me carefully. The function of generatePassword has been created. The password is being generated. When to call the function of generatePassword? First of all, when we are changing the length here, then we should see the password changing. When we are and not allowed, then we should see a new password. When we are doing character allowed and not allowed, then we should see a new password. After that, if we do reset password, then it will be reset. If we do save password, then it should be saved. So, these three things should be changed. So, will we put on change here every time? Here is the input on change, will we put it here? You can put it, no problem. You can run the function here too. You can run 2, 4, 10, as many functions as you want. but you will call only one function everywhere, it is better you put dependency in use effect here, you know how this use effect works, now it is running only once on reloading, but if I put dependency here, that whenever length will change, generate password call, then will it not do this? definitely it will do, If I put dependency here, is number allowed? If number allowed is true or false, then generate password again. I put dependency. If I put this character allowed, then whenever, whenever, whenever, allowed, first I put all, okay. If I put this character allowed, then whenever, character allowed or not allowed, again it will generate password. Okay. Really? Yes. See, I reload. This is password generate. I allowed number. Again password generate happened. I allowed character. Again, password generated. Can you see it? Okay. And again, our number is not coming here. It is coming. Actually, our number is coming. I allowed number. So, look here. Number is also coming. Okay. Is it O or 0? We will see now. We will bring password here. So, you will be able to see it properly. Let's remove console. We show password properly here. In our input box, which we made to show. So, here is password. here we will give value password so whatever password will be set it will be visible here reload so password is not visible why ok password we have set so set password first then only it will be visible so here in the last set password this password is made we will set this password so now here I am changing the length, the password is increasing, I have allowed the number, see the number has come in the middle, 5, 2 and 5, the number has come, I have allowed the character, see the character has also come in the middle, the password has been changed, so when all these things change, when the length changes, the password is changing, I am changing this, then also the password is changing, and this is getting selected, so select it by coming here, this is the input box, select should not be anything, so Select all of them. Now, it won't be selected. Very good. I'm allowing number, so it's working. I'm allowing character, so it's working. Password is being generated properly. Very good. So, you understood proper use of use effect. And it's saying to give 120. So, give 120. Otherwise, it will keep giving yellow yellow suggestion. 120. Okay. No problem. No problem at all. So, here you have almost everything. You have understood the use state properly. How, when, what to use. You have made the function of generate password by applying your logic properly. And here you have seen that you have to apply use effect and give proper dependency. So that it is running properly. Whenever the length changes, then password is being generated. Whenever number is allowed or disallowed, not allowed, then also password is being generated. Or character is allowed or not allowed, then also password is being generated. New password. Okay. So, this is done. Now, the Our main work is done and the other important work is to copy the password. Reset is very easy. What is the problem in resetting? Is there any problem in resetting? In reset password, put onclick. Do not do much. In reset password, set the length of 8 and set isNumberAllowed to false. And then set is character allowed. False. This is reset password. You have made controlled component. It is a problem. Will you change it in state? It is done. Okay. Controlled component. This is what I was teaching. In the last 3-4 lectures. It is controlled component. So, as soon as you reset here. As I changed password. I allowed number. I allowed character. You will reset here. This is reset. Okay. Number allowed. Character allowed. It did not change. Why? False. When we have done. Still, it did not happen. We will have to see. Why didn't it happen? So, here, in input, we have given isNumberAllowedValue here. Okay. Sorry, sorry, sorry, sorry. I am so sorry. Here, it is checked. I am so, so, so, so, so sorry. And here also, it will be checked definitely. I am so sorry. I am so sorry. I will do it like this and reset it. Now it is working properly. Number allowed. Character allowed. Okay. And here I have done this. Reset it. So, our password is being reset properly. Okay. So, this much work is done. Reset is also done. If you do save password, it should be saved. So, what will we do for this? Nothing much for this. We will make an array. You know that you have made normal todo. So, const array comma set array. Let's write saved password. Saved passwords, set saved passwords. Wait a minute. The laptop is discharged. Let me connect the battery. So set saved password is equal to use state. And here it will be an empty array. And we will map this saved password here. Where to map? At the very bottom. Here, savedPassword.map. Each item is coming. Basically, each password is coming to you. Okay. Higher order function. Each item is coming to you. And you have to return. Return one paragraph here. Item. So, you will be able to see the whole password. Okay. So here if the password comes, then it will be seen how it will come here. So whenever we will do it on the same password, then the password that has been made will be pushed in this area. So how will it happen? So let's see where we have made it. Where is the save password button? Here is the save password button. Here you put on click quickly like this. And what do you have to do here? You have to put it in the area. Just like the save password, put the password in the area. Put whatever password has been made in the area. It is very simple. Set saved password. Set saved password. And here whatever old password you have. Saved password. With that, here you have to add the new password. No problem. The old password in the saved password state, I have spread it here. If there are 2-3 passwords, then that password will come here. And the password that is being made now, that password will be added. And if there is no password, then the new password will be added. That's it. Here you can also do functional update. In all these cases, we mostly update the function here. In this way, you will get the previous password. Previous password. And here you put a bracket. And dot dot dot previous password came here. And put the new password here. You can do this too. We have studied all this. We have done it in a very proper way. And why did you put a bracket here? If we didn't put, would our work be done? If we didn't put this bracket here, then definitely work would be done. But if it was an object, then our work would not be done. Then syntax error would be coming. So put bracket, it is better. And if you want to return, then put curly braces, it is better. But this one is also fine. So now let's see if password is being saved or not. So now this is the password, let's save it. So yes, password is saved. Okay, we didn't give key prop, so give key prop also here. Give me the item in the key. Password, oh man, the laptop is shut down again. Alright, so again, I saved the password like this and this password is saved here. Suppose I changed the password here and saved it again. See, one more password has come here. I allowed the character and this long password has been made. I saved it. Here one more password has been saved. So we are also saving the password and if you want you can apply local storage session storage here so that your password doesn't get lost. We will definitely reload it now so it will be finished. So you can use local storage here. I have told you in JavaScript. If you say, I will recap your local storage in some project. But for now, our main purpose was use state, use effect and along with that, The main issue is the use case of the use reference. Understand. So now the use reference is going to come. Reset password is done. Save password is done. Copy password. See how it will be made. Here your proper way. One minute. Where were we? Here. Okay. So how to use use reference? You will know here. How to use? You saw this in the last lecture. You will know the use case now. So here. I'll make one more function. copy password to clipboard. Copy password to clipboard. Now, how will we copy? How will we copy the password to clipboard? So, quickly tell me how to copy. So, you must have read the way to copy in JavaScript. Okay. To copy, you don't have to do much tough work. Here, simply, you have to use Navigator API. like this navigator.clipboard you just have to use this navigator.clipboard.write text you have these suggestions i also don't remember anything so navigator.clipboard.write text And here, the password which is closed should be copied to the clipboard. So, I have put this. So, this much should be copied to the clipboard. Okay. So, here, let's call this function on the copy button. Where is our button? It is lost. Here it is. On click. We have passed the reference of the copy password to clipboard function. Okay. So, is this being copied? Let's see. So here we have made this password, we have made a copy. and let's paste it here. Yes, the password is fine. It is being copied. The password is being copied. Alright. Okay. In this one, I was confused. If not, then let's do Google. You can also do it. If you are not getting Google, then take all these hints. It is not that you have learned all the things by default or if you are not getting it, then something is wrong. You can see. How will it be copied in Flipboard? At least you can see that some things are made or you have to make something. You can definitely see. So, I am using Navigator after a long time. Definitely, I remember Navigator.Clipboard.WriteText has been copied to your clipboard. Now what we have to do is, we are copying but we don't know that it has been copied. We have clicked on copy, but we didn't know that it is highlighted when it is copied. You must have seen that it is highlighted when it is copied. How to do that? You have to do DOM manipulation. In the input field, you have to do selection true. Basically, you have to select. Like DOM manipulation, there is nothing in React. So here you know that you can use reference and work on it. It works in the same way as in DOM. Rest you can see in previous lecture, you will understand how it works. So now I will tell you how to do it. So const, here I will make input in password ref. I will give the name password ref. Oh man, wait const. password ref is equal to use ref use ref hook you have to use and here by default I will give null ok so here use ref see automatically imported so I gave null in use ref our password ref is done now this password ref ok whose reference do you want think this reference here you have used the powers of use reference you have called use ref hook now whose reference do you want whoever you want pass this password ref so I want this input field reference So, I will pass this password reference in reference. Now, in this variable of password reference, the reference of your input field has come. Really? Yes, really. I am saying absolutely true. You can console password ref if you want. I will do console here. CLG password ref. So, let's come here. Let's reload. I have copied password. So, see this. What is coming here? Whose reference is coming? Which is in current? This is input. If you copy the password ref in this way, suppose you put it in a button, put it in a button in this place, then see what you are getting here. Let's reload. I said copy, see what you are getting here. You are getting a button, a button reference is coming. So here the light has gone, let's do it quickly. Here we have given the reference of the password. So you have the password reference, now what do you have to do? Nothing much. Password reference dot current dot select. Is it select? It is selection. Let's do it. If there is an error, then it will be known that it is wrong. Right? So, here I said copy password. Yes, it is selected. It is selected. Copy password. It is selected. So, here we are knowing that yes, we have copied. Oh, man. Yes, okay. So, see this has been copied. I took this big password. Number allowed. Character allowed. I said copy. Copy has been copied. Wow. See this. Okay. Fun. Copy has been copied. Fun. Okay. Here you can do one more thing. Just for fun or optimization. Just for optimization. You can do one more thing here. You can do. You can fix selection range here. Password. reference.current.setSelectionRange. Now, what happens with this? Suppose, I have given 3 here. In selection range, I have given 3. So, I have to give 3 or I have to give starting. Suppose, I have copied here. This is happening completely. Here, two things have to be given. From where to where you have to select. So, I have given 0 to 3. So, now I will copy. So, see here. Your third index is not included. It is selected only till the second index. If I give 4 here, then it is selected only till 4. So just for optimization, you can make one here. What can you make? You can define maximum cost, maximum limit. It is 100. Maximum length. Maximum length is equal to 100. and this maximum length, you can put here in the range, put maximum length here and also put it here. So now you have been optimized, maximum length can go as much as it is here, you will never have more than that. If someone has made it too long, then he will only select till 100, he can't do more than that. Because we have also added selection range here. Okay. So now it will work properly. So for now it is 100 maximum. So definitely it will be fully selected. Number allowed. Character allowed. Copy is also done. And we are able to save here. Save is also happening. I have allowed number ds. I have made it small. I have saved. Save is also happening. And even if we are copying together. So copy is also happening. So it is fun. It is fun. Okay. So it must have been a lot of fun to make. And the laptop has been discharged. and our project is also completed, so there is no need to worry. If you want, you can take a recap here. I will give a recap quickly. Here we have defined the maximum length just for optimization. You know the password, set password, to keep the password, you know the length, to increase or decrease the length, you know the number allowed, if the number is there, then we will tick it, if not, then we will not do it, we want the character allowed or not, and we have taken the save password as an error to save the password. Why have we taken the password reference? To show that selection, to show. We made a function of generatePassword. We took a string. If the number will be allowed, then we added a number in the string. If the character will be allowed, then we added a character in the string. We ran a loop. We have to pick the length from the middle. If we have to pick from the middle, then we need a random index. For random index, we did mat.random into str.length. So that we get the same range. We did mat.floor. We needed the lower value. We picked the character on the random index. We picked it. So we will add one character in the password. If it is 8 length, then we will add 8 times. Password will be generated. Password will be generated. We have set the password. We have used useEffect so that we don't have to call on change again and again. If the length changes, then also it will change. If the number changes, basically if this number is not allowed, then also our password will be called. Generate password and password will be generated. In copy to clipboard, we have called the navigator API to save it in clipboard. And we have selected password.current.select. We have defined a selection range just for optimization. And then you know all these things, just remember in the checkbox, here you have to keep in mind, type checkbox, sorry, keep in mind that here you have to do checked instead of value. Okay, what do you have to do instead of value? You have to do checked. And here we have not done it in number? Yes, we have done it in number too, okay, checked. So all the rest of the things are fine, you must have understood that we will empty everything in reset, like it was old, right? And you understood the saved password too, so it was a very small project. And you must have enjoyed it. You must have made it yourself, I think. So, tell me how was it. And then we will meet in the next lecture. Till then, explore something from yourself. Make new projects from yourself. And then we will move forward. It will be fun and further. Okay. Bye-bye.