<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Angelo 👨🏾‍💻</title>
    <description>The latest articles on DEV Community by Angelo 👨🏾‍💻 (@pandersail).</description>
    <link>https://dev.to/pandersail</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1003660%2Fc6477ad5-0b65-4f9e-a747-9f5c6cd28722.png</url>
      <title>DEV Community: Angelo 👨🏾‍💻</title>
      <link>https://dev.to/pandersail</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pandersail"/>
    <language>en</language>
    <item>
      <title>How to create a Password Generator using JavaScript</title>
      <dc:creator>Angelo 👨🏾‍💻</dc:creator>
      <pubDate>Sun, 15 Jan 2023 19:19:38 +0000</pubDate>
      <link>https://dev.to/pandersail/how-to-create-a-password-generator-using-javascript-2321</link>
      <guid>https://dev.to/pandersail/how-to-create-a-password-generator-using-javascript-2321</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ztdjchso45yj8jykqak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ztdjchso45yj8jykqak.png" alt="Image description" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you tired of using the same old boring passwords? Look no further, because with our interactive password generator, you can now create a unique and secure password tailored to your specific needs.&lt;/p&gt;

&lt;p&gt;First, let’s set the scene. Imagine you’re standing in front of a giant vault, ready to lock away all of your precious online accounts. But, oh no! You realize that you don’t have the key, also known as a strong password.&lt;br&gt;
Don’t fret, because our password generator is here to save the day. &lt;/p&gt;

&lt;p&gt;Upon running the code, you’ll be greeted with an exciting welcome message, “&lt;em&gt;Welcome to the web’s safest password generator.&lt;/em&gt;”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alert(“Welcome to web’s safest password generator”)// Welcome alert
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Next, our trusty code will prompt you to choose the length of your desired password. But beware, the vault has strict rules and only accepts passwords between 10 and 64 characters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function to prompt user for password options
function getPasswordOptions() {

  i = 0
  while (i &amp;lt; 1) {
// while loop to include break property in case of non-accepted input

passwordLength = prompt("How many characters-long do you want your password to be?")

if (passwordLength &amp;lt; 10 || passwordLength &amp;gt; 64 || passwordLength % 1 !== 0) {
  alert("You have to choose a number between 10 and 64. Please try again.")
  break;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The prompt only accepts numbers and they have to be between 10 and 64, thanks to ||, any incorrect input will break.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Now it’s time to customize the combination of your password. Do you want to include lowercase letters? Uppercase letters? Numbers? Special characters? Our code will guide you through each step, ensuring that your password has the perfect balance of characters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; lowerCaseCharacters = confirm("Do you want include lower-case characters in your password?")
  upperCaseCharacters = confirm("Do you want include upper-case characters in your password?")
  numberCharacters = confirm("Do you want include numbers in your password?")
  oddCharacters = confirm("Do you want include special characters in your password?")
// Type of characters confirm notifications

  if (lowerCaseCharacters === false &amp;amp;&amp;amp;
      upperCaseCharacters === false &amp;amp;&amp;amp;
      numberCharacters === false &amp;amp;&amp;amp;
      oddCharacters === false) {
        alert("You have to choose at least one type of character to make-up the password. Please try again.")
        break;
      };
// Non-accepted conditions for type of characters where it breaks to start again
  I++ 
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;These lines of code uses the JavaScript confirm() method to display a dialog box with a question “Do you want include lower-case characters in your password?”. &lt;br&gt;
The user can then click “OK” or “Cancel” to confirm or deny the inclusion of lowercase characters in their password. The value returned from this confirm() method is then stored in the variable lowerCaseCharacters. &lt;br&gt;
Rinse and repeat for subsequent arrays.&lt;/em&gt;&lt;/p&gt;



&lt;p&gt;The code then checks to make sure that the user has selected at least one type of character to include in their password&lt;br&gt;
But that’s not all, our code goes above and beyond to keep your password extra secure. It randomly shuffles the characters in each array to increase the randomness of your password. &lt;/p&gt;

&lt;p&gt;It’s like spinning the dials on a safe, but without the risk of getting locked out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function for getting a random element from an array
function getRandom(arr) {
  let allArrays = []; //included allArrays locally (instead of globally) so we don't have to reload the page to generate another password
  i = 0
  while (i &amp;lt; 1) {
//randomizes arrays
                     specialCharacters.sort(() =&amp;gt; Math.random() - 0.5);
                     randomNumbers = numericCharacters.sort(() =&amp;gt; Math.random() - 0.5);
                     lowerCasedCharacters.sort(() =&amp;gt; Math.random() - 0.5);
                     upperCasedCharacters.sort(() =&amp;gt; Math.random() - 0.5);

// checking user's input if true will utilise the above math.random arrays + brings all arrays together in one array if true
if (lowerCaseCharacters === true) {
  allArrays = allArrays.concat(lowerCasedCharacters);
}

if (upperCaseCharacters === true) {
  allArrays = allArrays.concat(upperCasedCharacters);
}

if (numberCharacters === true) {
  allArrays = allArrays.concat(randomNumbers);
}

if (oddCharacters === true) {
  allArrays = allArrays.concat(specialCharacters);
}

// randomizes the array
    randomArray = allArrays.sort(() =&amp;gt; Math.random() - 0.5);

//sets array length based on passwordLength input

    randomPassword = randomArray.slice(0,passwordLength) 

I++
  }
  return randomPassword
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;A function called getRandom(arr) is defined. This function will be used to randomly select an element from the arrays of characters that were defined earlier in the code. The function uses the JavaScript sort() method to randomly shuffle the elements in each array.&lt;br&gt;
These if statement checks the value of the variables. If it is true, it means that the user has selected to include lowercase characters in their password. The code then uses the JavaScript concat() method to add the elements to the randomArray.&lt;br&gt;
It then uses the JavaScript sort() method to randomly shuffle the elements in the randomArray variable. The function passed to sort() uses Math.random() and a subtraction operation to randomly order the elements in the array. This ensures that the elements in the randomArray are in a random order.&lt;br&gt;
Finally, it slices with slice() method to select a specific number based on the user’s initial input.&lt;/em&gt;&lt;/p&gt;



&lt;p&gt;Finally, the code will generate your unique password and store it in the randomPassword array, ready for you to use to lock away all of your important online accounts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function to generate password with user input
function generatePassword() {
    let finalPassword = getRandom();
    finalPassword = finalPassword.join("")
    return finalPassword
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;To end things it uses the join() method to convert the finalPassword variable, which is an array, into a string. The argument passed to the join() method, in this case, is an empty string (""). &lt;br&gt;
This means that the elements of the array will be concatenated without any separator, ready to be copied by the user.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;So don’t settle for a weak and easily hackable password, let our interactive password generator be your key to a safer online experience. &lt;a href="https://pandersail.github.io/password-generator/" rel="noopener noreferrer"&gt;Give it a try today!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>discuss</category>
      <category>product</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Easy Rock Paper Scissor’s game with JavaScript</title>
      <dc:creator>Angelo 👨🏾‍💻</dc:creator>
      <pubDate>Sat, 07 Jan 2023 20:07:55 +0000</pubDate>
      <link>https://dev.to/pandersail/easy-rock-paper-scissors-game-with-javascript-382d</link>
      <guid>https://dev.to/pandersail/easy-rock-paper-scissors-game-with-javascript-382d</guid>
      <description>&lt;h3&gt;
  
  
  Welcome to this tutorial on how to create a simple rock, paper, scissors game using JavaScript!
&lt;/h3&gt;

&lt;p&gt;(&lt;em&gt;Link for you to try at the bottom.&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;Are you ready to test your luck against the computer in a game of rock, paper, scissors? In this article, we’ll be discussing a code that allows you to play five rounds of this classic game, and see who comes out on top.&lt;/p&gt;

&lt;p&gt;But this isn’t just any ordinary game of rock, paper, scissors. This code has been designed to add a little bit of excitement and competition to the mix. Are you ready to see if you have what it takes to beat the computer? Let’s find out!&lt;/p&gt;

&lt;h4&gt;
  
  
  How the code works:
&lt;/h4&gt;

&lt;p&gt;The code starts off by defining an array called “play”, which contains the three options that you can choose from: “rock”, “paper”, and “scissors”. It also defines three variables: “wins”, “losses”, and “draws”, which will be used to keep track of the outcome of each round.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let play = [“rock”, “paper”, “scissors”];
let wins = 0;
let losses = 0;
let draws = 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, the code displays an alert message introducing the game and explaining the rules. It then enters a loop that will run for a total of five rounds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let introduction = ("Get ready – five rounds of rock, paper, and scissors are about to start! (User's consent not required.)");
alert(introduction)
let i = 0;
while (i &amp;lt; 5){
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During each round, the code will prompt you to enter your choice. It will then convert your answer to lowercase, so that it doesn’t matter whether you type in “rock”, “ROCK”, or “RoCk”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let hAnswer = prompt("How will it be, eh? You ought to choose!");
hAnswer = hAnswer.toLowerCase();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don’t try to slip-in a different word, &lt;em&gt;the game will reset if you do&lt;/em&gt;!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (
    (hAnswer !== "rock" &amp;amp;&amp;amp; hAnswer !== "paper" &amp;amp;&amp;amp; hAnswer !== "scissors")
) {
    alert("Dude play either rock, paper, or scissors. Reload the page to start again.");
    break; 
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But here’s where things get interesting. The code will then generate a random answer for the computer, using the “play” array and the “Math.random()” function. It will display an alert message showing the computer’s choice, and it will also keep you on the edge of your seat by adding a little bit of suspense with some dramatic music.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let cAnswer = play[Math.floor(Math.random() * play.length)];
if (hAnswer == "rock" || hAnswer == "paper" || hAnswer == "scissors") {
    alert("Computer has played " + cAnswer + ".");
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, the code will determine the outcome of the round based on the rules of rock, paper, scissors. If it’s a draw, the “draws” counter will be incremented. If you win, the “wins” counter will be incremented. And if you lose, the “losses” counter will be incremented.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Response for draw &amp;amp; counter
if (hAnswer === cAnswer) {
    draws++
    alert(`It's a draw. We're keeping tabs... (${draws})`)
}

//Response for win &amp;amp; counter
else if (
    (hAnswer == "rock" &amp;amp;&amp;amp; cAnswer == "scissors") ||
    (hAnswer == "paper" &amp;amp;&amp;amp; cAnswer == "rock") ||
    (hAnswer == "scissors" &amp;amp;&amp;amp; cAnswer == "paper")
) { wins++
    alert(`You have won ${wins} times, luck lol.`)
}

//Response for loss &amp;amp; counter
else {
    losses++
    alert(`You have lost ${losses} times ahaha!`)
} i++ //counter for &amp;lt;5 loop
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the end of the loop, the code will display an alert message showing the final results, including the number of wins, losses, and draws. It will also add a little bit of flair by adding some celebratory music if you win, or some commiserating music if you lose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alert(`You have won ${wins} times, draw ${draws} times and lost ${losses} times.`)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Conclusion:
&lt;/h4&gt;

&lt;p&gt;So there you have it — a code that allows you to play rock, paper, scissors against your computer in a fun and exciting way. Whether you’re a seasoned pro or a beginner, this code is a great way to test your luck and see if you have what it takes to beat the computer. So why wait? Give it a try and see if you have what it takes to come out on top! 👀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pandersail.github.io/Rock-Paper-Scissor/"&gt;Try it here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
