Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>oy mate</title>
- <style>
- body{
- background-color: lavender;
- }
- div
- {
- color: lightblue;
- font-family: fantasy;
- text-align: right;
- font-size: 3em;
- text-shadow: 2px 2px lightslategray ;
- animation: meMove 5s linear infinite alternate ;
- white-space: nowrap;
- }
- @keyframes meMove
- {
- from {margin-right: 100%;}
- 50% {margin-right: 0%;}
- to {margin-right: 100%;}
- }
- a{
- text-decoration: none;
- color: mediumaquamarine;
- text-shadow: -1px 1px gray;
- }
- </style>
- </head>
- <body>
- <div id="Initial">Initial Array</div>
- <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"><p id="initialArray"> </p></a>
- <div id="SemiFinal">Array after generating passwords</div>
- <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"><p id="iterative"> </p></a>
- <div id="Final">Array after generating passwords recursively</div>
- <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"><p id="recursively"> </p></a>
- <script>
- var users=[
- {
- name:"Nabil", password:""
- },
- {
- name:"Amal", password:""
- },
- {
- name:"Melek", password:""
- },
- {
- name:"Walid", password:""
- },
- {
- name:"Farah", password:""
- },
- {
- name:"Ibrahim", password:""
- },
- {
- name:"Chedi", password:""
- },
- {
- name:"Rostom", password:""
- },
- {
- name:"Rostom", password:""
- }
- ];
- document.getElementById("initialArray").innerHTML = JSON.stringify(users, null, 2);
- // this is the only line in code that I Don't udnerstand ^
- for ( var a=0; a<users.length;a++)
- {
- console.log(users[a]);
- }
- console.log("_____________We Did It Boys, Password Error Is No More___________________")
- function generateRandomPassword(length)
- {
- var pass="";
- var stringOfChars ="azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN";
- for (var a =0; a<length;a++)
- {
- pass += stringOfChars.charAt(Math.floor(Math.random()* stringOfChars.length));
- }
- //console.log(pass);
- //console.log(length);
- return pass;
- }
- for (var a=0; a<users.length;a++)
- {
- let randomLength= Math.floor(Math.random()*6 +10) ;
- users[a].password=generateRandomPassword(randomLength);
- console.log(users[a],"password length= "+randomLength);
- }
- document.getElementById("iterative").innerHTML = JSON.stringify(users, null, 2);
- // this is the only line in code that I Don't udnerstand ^
- console.log("____________We Did It Boys, Password Error Is No More V2__________________")
- function recursivePasswordGenerator (users,size)
- {
- var passwordLength= Math.floor(Math.random()*6 +10);
- users[size].password=generateRandomPassword(passwordLength);
- console.log(users[size],"PassLength= "+passwordLength);
- if (size ==0)
- {
- return;
- }
- else {
- recursivePasswordGenerator(users,size-1);
- }
- }
- recursivePasswordGenerator(users,users.length-1)
- document.getElementById("recursively").innerHTML = JSON.stringify(users, null, 2);
- // this is the only line in code that I Don't udnerstand ^
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment