<?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: Tatiana Bowman</title>
    <description>The latest articles on DEV Community by Tatiana Bowman (@tatianabowman).</description>
    <link>https://dev.to/tatianabowman</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%2F910767%2F4ab63d9f-4e93-4cad-87ce-aab02e93f997.JPG</url>
      <title>DEV Community: Tatiana Bowman</title>
      <link>https://dev.to/tatianabowman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tatianabowman"/>
    <language>en</language>
    <item>
      <title>Conversion Functions: converting between binary, hexadecimal, decimal, &amp; ASCII</title>
      <dc:creator>Tatiana Bowman</dc:creator>
      <pubDate>Fri, 05 May 2023 16:56:44 +0000</pubDate>
      <link>https://dev.to/tatianabowman/conversion-functions-converting-between-binary-hexadecimal-decimal-ascii-f13</link>
      <guid>https://dev.to/tatianabowman/conversion-functions-converting-between-binary-hexadecimal-decimal-ascii-f13</guid>
      <description>&lt;p&gt;Conversion functions help computer programs to change information like numbers or letters from one type to another. For example, we can use conversion functions to change the number "10" into its binary equivalent "1010". Conversion functions are important because computers work with different types of information and formats, and sometimes they need to change one type of information into another to perform a specific task or operation.&lt;/p&gt;

&lt;p&gt;In order to convert those types we need tools like built-in functions to help us. More specifically the built in functions: &lt;em&gt;parseInt()&lt;/em&gt;, &lt;em&gt;toString()&lt;/em&gt;, &lt;em&gt;charCodeAt()&lt;/em&gt;, &lt;em&gt;String.fromCharCode(&lt;/em&gt;), and &lt;em&gt;substring()&lt;/em&gt;. Before I show you some examples of the usage, let me explain what binary, hexadecimal, decimal, &amp;amp; ascii are as well as what exactly the built-in functions do.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are binary, hexadecimal, decimal, &amp;amp; ascii?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Binary&lt;/strong&gt; (also known as &lt;strong&gt;Base-2&lt;/strong&gt;) is a numbering scheme in which there are only two possible values for each digit,  0 or 1 and these are also the values that computers happen to be stored in. Binary numbers are often represented with 0b at the beginning.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0b11001010
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;side note:&lt;/strong&gt; The word &lt;em&gt;bits&lt;/em&gt; is short for &lt;em&gt;binary digits&lt;/em&gt; and a group of &lt;em&gt;8 bits&lt;/em&gt; is known as a &lt;em&gt;byte&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hexadecimal&lt;/strong&gt; (also known as &lt;strong&gt;Base-16&lt;/strong&gt;) is often used as shorthand for representing binary values: one hex digit can represent four bits. The digits are 0-9 with A-F representing 10-15. A hexadecimal is often represented with 0x at the beginning.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 0xF23C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Decimal&lt;/strong&gt; (also known as &lt;strong&gt;Base-10&lt;/strong&gt;) is the most commonly used system. It uses 10 symbols (0-9), to represent numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ASCII&lt;/strong&gt; (which is short for American Standard Code for Information Interchange) is a character encoding system that assigns unique numerical codes to represent a set of characters used in computers. It's a seven-bit code meaning it can represent up to 128 characters, including numbers, letters, punctuation marks, and control codes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ASCII CODE FOR "B" =&amp;gt; 01000010 in binary 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Built-in functions: &lt;em&gt;parseInt(), toString(), charCodeAt(), String.fromCharCode(),&lt;/em&gt; and &lt;em&gt;substring()&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;parseInt()&lt;/strong&gt; is a function that parses a string argument and returns an integer of the specified radix (&lt;em&gt;the radix or base is the number of unique digits, including the digit zero, used to represent numbers.&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;parseInt(string, radix)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;toString()&lt;/strong&gt;  returns a string representing the object&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let number = 1;
number.toString();
=&amp;gt; "1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it can also be used to convert decimals into binary or hexadecimal by taking the radix that specifies the base of the number system to be used for conversion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;binary: base-2 =&amp;gt; radix = 2 | hexadecimal : base-16 =&amp;gt; radix = 16 | decimal: base-10 =&amp;gt; radix = 10

example: 

let number = 255;
let hex = number.toString(16);
=&amp;gt; "ff"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;charCodeAt()&lt;/strong&gt; returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function charGreeting(greeting) {
  let greetCode = [];

for(let i = 0; i &amp;lt; greeting.length; i++) {
 greetCode.push(greeting.charCodeAt(i))
}
return greetCode;
}

charGreeting("Hey")
=&amp;gt; [104, 101, 121]

H =&amp;gt; 104
e =&amp;gt; 101
y =&amp;gt; 121
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String.fromCharCode&lt;/strong&gt; returns a string created from the specified sequence of UTF-16 code units.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function charGreeting(charCode) {
  let greeting = [];

for(let i = 0; i &amp;lt; charCode.length; i++) {
 greeting.push(String.fromCharCode(charCode[i]))
}
return greeting.join("");
}

stringCharCode([104, 101, 121]
=&amp;gt; "hey"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Substring&lt;/strong&gt; returns the part of the string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = "Tatiana"
name.substring(3)
=&amp;gt; "iana"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conversion Function Examples &amp;amp; Breakdowns
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;converting binary and hexadecimal to decimals&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingBinarytoDecimal = binary =&amp;gt; {
  let binaryRemoval = binary.substring(2)
  let decimal = parseInt(binaryRemoval, 2)
  return decimal;
}

convertingBinarytoDecimal('0b0101')    
=&amp;gt; 5

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First the function removes the first two characters of the binary string, which are the prefix 0b, and stores the resulting string in the variable binaryRemoval.&lt;/p&gt;

&lt;p&gt;The function then uses the parseInt function to convert the binaryRemoval string to a decimal number. The 2 radix (base) is passed as the second argument to parseInt, indicating that the input is a binary number. The resulting decimal value is stored in the variable decimal.&lt;/p&gt;

&lt;p&gt;Finally, the function returns the decimal value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;note:&lt;/strong&gt; &lt;em&gt;something you will notice is that converting binary and hexadecimal are done the exact same way, the only differences are the base numbers.&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;const convertingHexToDecimal = hexadecimal =&amp;gt; {
 let hexRemoval = hexidecimal.substring(2)
 let decimal = parseInt(hexRemoval, 16)
 return decimal;
}
convertingHexToDecimal('0x51')   
=&amp;gt; 81
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;converting decimals to hexadecimal and binary&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingDecimalToBinary = decimal =&amp;gt; {
   let binary = decimal.toString(2)
   return `0b${binary}`
}

convertingDecimalToBinary(13) 
=&amp;gt; '0b1101'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, the function converts the decimal number to a binary string by calling the toString method on the decimal variable with a 2 radix (base) as the argument. The resulting binary string is stored in the variable binary.&lt;/p&gt;

&lt;p&gt;Finally, the function concatenates the string 0b with the binary string and returns the resulting string, which represents the binary equivalent of the original decimal number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function convertingDecimalToHexadecimal(decimal) {
  let hex = decimal.toString(16)
  return `0x${hex}`
}

convertingDecimalToHexadecimal(9) 
=&amp;gt; '0x9'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;converting binary to hexadecimal and hexadecimal to binary&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingBinaryToHex = binary =&amp;gt; {
  let binaryRemoval = binary.substring(2)
  let decimal = parseInt(binaryRemoval, 2)
  let hex = decimal.toString(16)
  return `0x${hex}`
}

convertingBinaryToHex('0b1010')
=&amp;gt; '0xa'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function starts by removing the first two characters of the binary (0b) and stores the resulting string in the variable binaryRemoval. Then converts the binary number to decimal by calling the parseInt function with the binaryRemoval string as the first argument and the 2 radix (base) as the second argument. The resulting decimal number is stored in the variable decimal.&lt;/p&gt;

&lt;p&gt;Next, the function converts the decimal number to hexadecimal by calling the toString function on the decimal variable with the 16 radix as the argument. The resulting hexadecimal string is stored in the variable hex.&lt;/p&gt;

&lt;p&gt;Finally, the function concatenates the string 0x with the hex string and returns the resulting string, which represents the hexadecimal equivalent of the original binary number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingHextoBinary = hex =&amp;gt; {
  let hexRemoval = hex.substring(2)
  let decimal = parseInt(hexRemoval, 16)
  let binary = decimal.toString(2)
  return `0b${binary}`
}

convertingHextoBinary('0xa1')  
=&amp;gt; '0b10100001'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;converting binary and hexadecimal to ASCII&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingBinarytoASCII = (binary) =&amp;gt; {
  const binaryPrefixRemoval = binary.substring(2)
  const decimal = parseInt(binaryPrefixRemoval, 2)
  return String.fromCharCode(decimal)
}
convertingBinarytoASCII("0b01000010")
=&amp;gt; B

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, the function removes the first two characters of the binary string, which are the prefix 0b, and stores the resulting string in the variable binaryPrefixRemoval.&lt;/p&gt;

&lt;p&gt;The function then converts the binary number to decimal by calling the parseInt function with the binaryPrefixRemoval string as the first argument and the 2 radix (base) as the second argument. The resulting decimal number is stored in the variable decimal.&lt;/p&gt;

&lt;p&gt;Finally, the function uses the String.fromCharCode method to convert the decimal value to its corresponding ASCII character. The ASCII character is returned by the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingHextoASCII = (hex) =&amp;gt; {
  const hexPrefixRemoval = hex.substring(2)
  const decimal = parseInt(hexPrefixRemoval, 16)
  return String.fromCharCode(decimal)
}

convertingHextoASCII("0x43")
=&amp;gt; C

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;converting decimal to ASCII and ASCII to decimal&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingDecimalToAscii = decimal =&amp;gt;  {
  return String.fromCharCode(decimal)
}

convertingDecimalToAscii(65) 
=&amp;gt; "A"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function uses the String.fromCharCode method to convert the decimal value to its corresponding ASCII character. The ASCII character is returned by the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertingAsciiToDecimal= ASCII =&amp;gt; {
  let decimals = []
  for(let i = 0; i &amp;lt; ASCII.length; i++) {
     decimals.push(ASCII.charCodeAt(i))
  }
  return decimals
}

 convertingAsciiToDecimal('HELLO'))
=&amp;gt; [ 72, 69, 76, 76, 79 ]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function creates an empty array called decimals then using a for loop, the function iterates over each character of the ASCII string, one at a time. For each character, the function calls the charCodeAt method, passing the index of the character in the string as an argument. This method returns the Unicode value of the character, which corresponds to the decimal value of the ASCII character. The decimal value is then added to the decimals array using the push method.&lt;/p&gt;

&lt;p&gt;After iterating over all characters in the ASCII string, the function returns the decimals array, which contains the decimal values of each ASCII character in the original string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, conversion functions are crucial for converting between different data types and formats, including binary, hexadecimal, decimal, ASCII, and others. Being able to convert between these formats is essential for data manipulation, encoding, and decoding. Understanding how to use these conversion functions is fundamental for all developers and can improve their coding efficiency and versatility.&lt;/p&gt;

</description>
      <category>conversionfunctions</category>
      <category>dataconversion</category>
      <category>typeconversion</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Creating demos for your web applications</title>
      <dc:creator>Tatiana Bowman</dc:creator>
      <pubDate>Fri, 28 Apr 2023 15:57:13 +0000</pubDate>
      <link>https://dev.to/tatianabowman/creating-project-demos-14oj</link>
      <guid>https://dev.to/tatianabowman/creating-project-demos-14oj</guid>
      <description>&lt;p&gt;Recording a demo for your application can be an effective way to showcase its features to recruiters and potential users. It'll help them better understand how your project works and what it can do. Highlighting the key features and giving visual representation can help you stand out and increase your chances of landing a job during your search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here are a few tips:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create a script&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;creating a script or giving yourself guidelines to follow will make the recording process 10x's easier. I'll ensure that you cover everything that you want presented.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Opening&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure to introduce yourself before starting. Give a greeting, state your name, the name of the project as well as a brief description of what it is and why you chose it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Demonstration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure to speak clearly and at a steady pace, highlight each feature and if you want, include any stretch goals that you may have.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Closing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When wrapping up make sure to repeat your name and the name of the project as well as reiterating what the project does. Then end it by thanking the viewer for their time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Keep it short&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Try to keep your demo short, aim for a video that is no longer than five minutes long.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Example: *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Opening &lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hello! My name is &lt;strong&gt;[YOUR NAME HERE]&lt;/strong&gt; and this project is called &lt;strong&gt;[PROJECT NAME HERE]&lt;/strong&gt;! &lt;strong&gt;[A BRIEF DESCRIPTION OF THE WEBSITE]&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Middle &lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;[HOW DID YOU COME UP WITH THIS IDEA?]&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[  DEMO WEBSITE ]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;&lt;br&gt;
Closing &lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the future, I would really like to [STRETCH GOALS] But other than that that’s all I have! &lt;/p&gt;

&lt;p&gt;again my name is [YOUR NAME HERE] and my project is called [NAME OF WEBSITE AND BRIEF DESCRIPTION]! And Thank you for your time! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Screen recording tool&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Loom is a great tool for creating demos and is easy to use! You are able to download it on your computer as well as make it a Chrome extension for quick and easy access. It also allows you to trim and edit your videos if needed. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Recording demos for your projects can be an effective way to showcase your skills and help you stand out.&lt;/p&gt;

</description>
      <category>demos</category>
      <category>projects</category>
      <category>webdev</category>
      <category>jobsearch</category>
    </item>
    <item>
      <title>JavaScript Classes</title>
      <dc:creator>Tatiana Bowman</dc:creator>
      <pubDate>Mon, 06 Mar 2023 14:15:54 +0000</pubDate>
      <link>https://dev.to/tatianabowman/javascript-classes-odl</link>
      <guid>https://dev.to/tatianabowman/javascript-classes-odl</guid>
      <description>&lt;h2&gt;
  
  
  What are classes?
&lt;/h2&gt;

&lt;p&gt;Classes are a template for creating objects. They encapsulate data with code to work on that data. In JavaScript, classes are defined using the class keyword, followed by the name of the class, and a set of curly braces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;note:&lt;/strong&gt; &lt;em&gt;Class names should always start with a capital letter&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The class uses something called a constructor which is used for creating and initializing an object instance of that class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
    constructor(name, age, occupation, hobbies = []) {

   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;note:&lt;/strong&gt; &lt;em&gt;the variables can take in default values as seen above for hobbies.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Within the constructor method, we use the &lt;strong&gt;this&lt;/strong&gt; keyword, which references the newly created object instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
    constructor(name, age, occupation, hobbies = []) {
        this.name = name
        this.age = age
        this.occupation = occupation
        this.hobbies = hobbies
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create an instance of a class we use the &lt;strong&gt;new&lt;/strong&gt; keyword and the name of the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let tatiana = new Person(
    'Tatiana',
    21,
    'Software Engineer',
    [
        "Reading",
        "guitar",
        "working out",
        "movie theater rat"
    ]
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And once you console log the new instance you  should get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Person {
  name: 'Tatiana',
  age: 21,
  occupation: 'Software Engineer',
  hobbies: [ 'Reading', 'guitar', 'working out', 'movie theater rat' ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Class &amp;amp; Instance Methods
&lt;/h2&gt;

&lt;p&gt;Classes also use something called methods which is a function that is part of the class and performs an action for it. In javascript we have something called instance methods and static methods. An instance method is a method that is typically invoked on a given instance of the class stored in a variable. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Instance Method: *&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;aboutMe() {
    console.log(
        `My name is ${this.name} I'm ${this.age} years old, and I work as a ${this.occupation}!`
    )
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, I created a sentence using the variables from the constructor.&lt;/p&gt;

&lt;p&gt;Which in return should give you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;My name is Tatiana I'm 21 years old, and I work as a Software Engineer!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;when you call the method on the class instance like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tatiana.aboutMe()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A static method is invoked directly on a class, not on the instance. And The syntax for a static method is the same as an instance except that their declarations start with the **static **keyword.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Method:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static getOccupations(...people) {
     return people.map(person =&amp;gt; person.occupation)
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, I'm using the static method to collect the occupation from each instance and return them in an array. You then use the static method by calling it on the class and passing in the instance methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let occupations = Person.getOccupations(tatiana, peachy)
console.log(occupations)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;giving you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 'Software Engineer', 'Cafe Owner' ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Static Variables&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Along with the static methods, there is also something called &lt;em&gt;static variables&lt;/em&gt;. Static variables are declared like the **static **keyword, followed by the variable name and value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static peopleCount = 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a usage example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
    constructor(name, age, occupation, hobbies = []) {
        this.name = name
        this.age = age
        this.occupation = occupation
        this.hobbies = hobbies

    Person.peopleCount += 1;
   }
static peopleCount = 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, I'm using the static variable to keep track of the number of Person instances being made. I should get the output of 2 after using the variable on the Person class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(Person.peopleCount)

//output 

2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Putting it all together: *&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;class Person {
    constructor(name, age, occupation, hobbies = []) {
        this.name = name
        this.age = age;
        this.occupation = occupation
        this.hobbies = hobbies

        Person.peopleCount += 1
   }

   static peopleCount = 0;

   aboutMe() {
    console.log(
        `My name is ${this.name} I'm ${this.age} years old, and I work as a ${this.occupation}!`
    )
   }

   static getOccupations(...people) {
     return people.map(person =&amp;gt; person.occupation)
   }
}

let tatiana = new Person(
    'Tatiana',
    21,
    'Software Engineer',
    [
        "Reading",
        "guitar",
        "working out",
        "movie theater rat"
    ]
)

let peachy = new Person (
    "Peachy",
    "22",
    "Cafe Owner",
    [
        "Reading",
        "drums",
        "guitar",
        "roller skating"
    ]
)

// instance methods
tatiana.aboutMe()
peachy.aboutMe()


// static methods
let occupations = Person.getOccupations(tatiana, peachy)
console.log(occupations)

// static variable
console.log(Person.peopleCount)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Inheritance
&lt;/h2&gt;

&lt;p&gt;Classes also have something called &lt;em&gt;inheritance&lt;/em&gt; which allows the properties and methods defined on a parent class to be available for objects created from classes that inherit from those parent classes. &lt;/p&gt;

&lt;p&gt;To implement inheritance we use the extends keyword to say that this class inherits from another class.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Child extends Person {

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Super *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We then use something called the **super **keyword which is used to access properties on an object literal or class's Prototype, or invoke a superclass's constructor. &lt;/p&gt;

&lt;p&gt;The super keyword may appear as a "function call", and must be called before the this keyword is used. It calls the parent class's constructor and binds the parent class's public fields, after which the derived class's constructor can further access and modify this.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Child extends Person {
    constructor(firstName,age, occupation, hobbies, grade) {
    super(firstName, age, occupation, hobbies)
        this.grade = grade;
    }
}

let aisha  = new Child("A'isha", 9, "unemployed",["coloring", "dancing", "karate"], "5th" )
console.log(aisha)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;giving us:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Child {
  firstName: "A'isha",
  age: 9,
  occupation: 'unemployed',
  hobbies: [ 'coloring', 'dancing', 'karate' ],
  grade: '5th'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;note:&lt;/strong&gt; &lt;em&gt;make sure to add the super keyword, using inheritance w/o it will invoke a reference error.&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;ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Classes are a template for creating objects. They encapsulate data with code to work on that data. By using classes, you're ensuring that methods are only used on one set of data. Classes also provide an easy way of keeping the data members and methods together in one place which helps in keeping the program more organized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Helpful Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Classes_in_JavaScript"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Classes_in_JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>oop</category>
      <category>programming</category>
    </item>
    <item>
      <title>Using A Helper Function</title>
      <dc:creator>Tatiana Bowman</dc:creator>
      <pubDate>Mon, 13 Feb 2023 14:42:16 +0000</pubDate>
      <link>https://dev.to/tatianabowman/using-a-helper-function-37mn</link>
      <guid>https://dev.to/tatianabowman/using-a-helper-function-37mn</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2csU0AXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uy2n4jsenngmr5ydlhkl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2csU0AXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uy2n4jsenngmr5ydlhkl.jpg" alt="Image description" width="246" height="205"&gt;&lt;/a&gt;Using a helper function is pretty simple and it's a very useful tool that will help keep your code &lt;a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself"&gt;D.R.Y&lt;/a&gt; (Don't Repeat Yourself) and help you maintain the &lt;a href="https://en.wikipedia.org/wiki/Single-responsibility_principle"&gt;S.R.P&lt;/a&gt; (Single Responsibility Principle). Because of that it also makes our code easier to debug.&lt;/p&gt;

&lt;p&gt;A helper function is a function that is called within another function, and we are able to use the return value from that function being called.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;In this example I'm going to show you how a helper function can be used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function isPrime(number){
    if(number &amp;lt; 2) return false;

    for(let i = 2; i &amp;lt; number; i++) {
        if(number % i === 0) return false;
    }
    return true;
}


function collectPrimes(numbers){
    let primes = []
    for(let i = 0; i &amp;lt; numbers.length; i++) {
        let number = numbers[i]
        if(isPrime(number)) primes.push(number)
    }
    return primes;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal was to create a function that filtered out only the prime numbers and returned them in a new array. In order to do that and maintain the S.R.P, I had to break down the problem into two. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Breakdown
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function isPrime(number){
    if(number &amp;lt; 2) return false;

    for(let i = 2; i &amp;lt; number; i++) {
        if(number % i === 0) return false;
    }
    return true;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The isPrime (helper function) is taking in each number that is being sent up from collectPrimes (by calling it in the function and passing in the numbers) and checking if it is a prime number. If it is it will return true if not it will return false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function collectPrimes(numbers){
    let primes = []
    for(let i = 0; i &amp;lt; numbers.length; i++) {
        let number = numbers[i]
        if(isPrime(number)) primes.push(number)
    }
    return primes;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it gets back down to the collectPrimes function the conditional checks if we got a truthy value back from the isPrime function, then it pushes that prime into the primes array and returns a new array of primes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;side note:&lt;/strong&gt; &lt;em&gt;We could also refactor this code and make it cleaner by using the .filter method, which will iterate through. filter out the primes, and return a new array of only the prime numbers.&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;return numbers.filter(number =&amp;gt; isPrime(number))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;em&gt;If you are not familiar with array iteration methods like .filter check out my previous blog post called &lt;a href="https://dev.to/tatianabowman/the-fantastic-four-map-filter-foreach-reduce-array-iteration-methods-2722"&gt;The Fantastic Four: .map, .filter, .forEach, &amp;amp; .reduce array (iteration) methods&lt;/a&gt;&lt;/em&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Helpful Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Bt-fbCT7WFw"&gt;What are Helper Functions, How to Use a Helper Function in JavaScript, Programming with Codecademy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/what-are-the-helper-functions/"&gt;What are the Helper functions ?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>coding</category>
      <category>cleancode</category>
    </item>
    <item>
      <title>The Fantastic Four: .map, .filter, .forEach, &amp; .reduce array (iteration) methods</title>
      <dc:creator>Tatiana Bowman</dc:creator>
      <pubDate>Mon, 23 Jan 2023 15:01:21 +0000</pubDate>
      <link>https://dev.to/tatianabowman/the-fantastic-four-map-filter-foreach-reduce-array-iteration-methods-2722</link>
      <guid>https://dev.to/tatianabowman/the-fantastic-four-map-filter-foreach-reduce-array-iteration-methods-2722</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%2F6gofznl57is9459vuf62.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%2F6gofznl57is9459vuf62.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;An array (iteration) method is a function built into JavaScript that we use to apply to arrays. There are a few other great array methods but these particular four are always good to know and come in handy when needed. &lt;/p&gt;

&lt;p&gt;These methods take in four parameters: &lt;/p&gt;

&lt;p&gt;1.) A &lt;strong&gt;callback function&lt;/strong&gt; to execute for each element in the array. Its return value is added as a single element in the new array. &lt;/p&gt;

&lt;p&gt;2.) The &lt;strong&gt;element&lt;/strong&gt; being processed in the array. &lt;/p&gt;

&lt;p&gt;3.) &lt;strong&gt;Index&lt;/strong&gt; of the current element being processed in the array. &lt;/p&gt;

&lt;p&gt;4.) The &lt;strong&gt;array&lt;/strong&gt; the method was called upon. &lt;/p&gt;

&lt;p&gt;so it ends up looking something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array.arrayMethod(element, index, array) {
// action
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The array method &lt;strong&gt;&lt;em&gt;.Map()&lt;/em&gt;&lt;/strong&gt; creates a shallow copy of the original array populated with the results of calling a provided function on every element in the calling array. The result of the passed-in callback will be a new array with each element.&lt;/p&gt;

&lt;p&gt;For example say I want a new array with every element multiplied by two:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function double(numbers) {
    const doubled = numbers.map((number, i ,array) =&amp;gt; {
        return number * 2;
    })
    return doubled;
}

double(numbers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, I created a function that takes in an array of numbers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5]; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and using the map method it iterated over the array multiplying each number by two adding it to an array and returning in the place of the old one getting us this result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//  [1, 2, 3, 4, 5] =&amp;gt;  [ 2, 4, 6, 8, 10 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;side note:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;We can make this code so much cleaner! Because I'm not using the index or the array we can take those out of the parameter and just leave the element without the extra parentheses. We can also get rid of the variable that's holding the map function, the returns, and the curly braces so the whole inner function can just fit on one line of code like this:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return numbers.map(number =&amp;gt;  number * 2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next up we have the &lt;strong&gt;&lt;em&gt;.filter()&lt;/em&gt;&lt;/strong&gt; which just like &lt;strong&gt;&lt;em&gt;.Map()&lt;/em&gt;&lt;/strong&gt; returns an array of elements. It creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.&lt;/p&gt;

&lt;p&gt;for example, say I wanted an array of only the even numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function onlyEvens(numbers) {
 const evens = numbers.filter((even, i, array) =&amp;gt; {
    return even % 2 === 0;
 })
 return evens;
}

onlyEvens(numbers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using the filter method I was able to "filter" out any number that is % 2 === 0 thus giving me all the even numbers in a new array.&lt;/p&gt;

&lt;p&gt;here's a cleaner look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return numbers.filter(even =&amp;gt; even % 2 === 0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here's another example not involving math:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fiveAndBelow(words) {
    return words.filter(word =&amp;gt; word.length &amp;lt;= 5 )
}

fiveAndBelow(["lala", "land", "I", "independent", "cakey", "developer"])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["lala", "land", "I", "independent", "cakey", "developer"] =&amp;gt; [ 'lala', 'land', 'I', 'cakey' ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we have the &lt;strong&gt;&lt;em&gt;.forEach()&lt;/em&gt;&lt;/strong&gt; method which executes a provided function once for each array element callbackFn will not visit any elements added beyond the array's initial length when the call to &lt;strong&gt;&lt;em&gt;.forEach()&lt;/em&gt;&lt;/strong&gt; began._ (it's basically a for loop but less work)_&lt;/p&gt;

&lt;p&gt;for example, say you want to print out each element in an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function print(words) {
    return words.forEach(word =&amp;gt; console.log(word))
}

print(["lala", "land", "I", "independent", "cakey", "developer"])

*prints*
lala
land
I
independent
cakey
developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;&lt;em&gt;.forEach()&lt;/em&gt;&lt;/strong&gt; method iterated over the array and returned a console log of each element.&lt;/p&gt;

&lt;p&gt;Another example, say you want the total sum of an array of numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function findSum(numbers) {
    let sum = 0
    numbers.forEach(number =&amp;gt; sum += number)
    return sum;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method iterated over the array adding each element to the sum value giving us the overall sum of the array once returned.&lt;/p&gt;

&lt;p&gt;But of course for anything math-related like finding the total sum of an array you can also use &lt;strong&gt;&lt;em&gt;.reduce()&lt;/em&gt;&lt;/strong&gt; method.&lt;/p&gt;

&lt;p&gt;Speaking of &lt;strong&gt;&lt;em&gt;.reduce()&lt;/em&gt;&lt;/strong&gt; method it executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.&lt;/p&gt;

&lt;p&gt;unlike the other three reduce needs two more parameters the accumulator and initial value. The &lt;strong&gt;accumulator&lt;/strong&gt; which is the value resulting from the previous call to callbackFn. On first call, &lt;strong&gt;initial value&lt;/strong&gt; if specified, otherwise the value of array[0].&lt;/p&gt;

&lt;p&gt;(&lt;em&gt;&lt;strong&gt;So if you think back to the forEach method the initial value is basically the let sum = 0, and if you don't set one it will just latch on to the first index in the array and use that.&lt;/strong&gt;&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;for example, say you want the total product of an array of numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function findProduct(numbers) {
    return numbers.reduce((accum, num) =&amp;gt; accum *= num, 1)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The accumulator is holding on to that initial value iterating over the array and multiplying the elements together. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;side note:&lt;br&gt;
You can also one-line this whole function creating less and cleaner code by using a function expression instead of a function declaration:&lt;/strong&gt;&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;const findProduct = numbers =&amp;gt; numbers.reduce((accum, num) =&amp;gt; accum *= num, 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, although they might not be everyone's top choice the map, filter, forEach, and reduce methods are great tools to know and will always come in handy when needed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;:&lt;br&gt;
&lt;em&gt;Array Methods&lt;/em&gt;: &lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/javascript-array-iteration-methods/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/javascript-array-iteration-methods/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/Urwzk6ILvPQ" rel="noopener noreferrer"&gt;https://youtu.be/Urwzk6ILvPQ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Arrow functions&lt;/em&gt;:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/h33Srr5J9nY" rel="noopener noreferrer"&gt;https://youtu.be/h33Srr5J9nY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Function Expression&lt;/em&gt;:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/37ly8tCGFWA" rel="noopener noreferrer"&gt;https://youtu.be/37ly8tCGFWA&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devmeme</category>
    </item>
    <item>
      <title>If you can use a while loop you can use recursion (coming from a ex recursion hater)</title>
      <dc:creator>Tatiana Bowman</dc:creator>
      <pubDate>Fri, 23 Dec 2022 15:01:37 +0000</pubDate>
      <link>https://dev.to/tatianabowman/if-you-can-use-a-while-loop-you-can-use-recursion-coming-from-a-ex-recursion-hater-11b7</link>
      <guid>https://dev.to/tatianabowman/if-you-can-use-a-while-loop-you-can-use-recursion-coming-from-a-ex-recursion-hater-11b7</guid>
      <description>&lt;p&gt;I bet you've heard the phrase "If you can do it recursively you can do it iteratively" true but that still didn't make me hate it any less when I first started learning it. Recursion was a huge pain but once you get the pattern down even a little it's easier and becomes a very useful tool. One thing that helped me was realizing that while loops (which I love) and recursion are basically the same thing just slightly different code.&lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;What is recursion? *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Recursion is the act of a function calling itself within itself. When solving with recursion you need two things 1. a base case which is used as a sort of stopper for the function and 2. a recursive call which is the act of the function calling itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5ysy51tjmnqaahvd3a63.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5ysy51tjmnqaahvd3a63.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5jk378o76a0dp1fc16g7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5jk378o76a0dp1fc16g7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above I started with a base case that states if the number is less than or equal to zero print "Happy New Year", so when the number gets down to zero it will print the message. &lt;/p&gt;

&lt;p&gt;The way to get it to zero is through the recursive call on line 9, as you can see every time I call the function it decrements the number by one getting it closer and closer to the base case. &lt;/p&gt;

&lt;p&gt;So you call the function it takes the number and checks if it's equal to zero if it isn't it'll print, decrement by one then get called again but as a smaller number each time.  &lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a while loop?
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
A while loop creates a loop that executes a statement as long as the condition evaluates to true. A while loop can be used just like a for loop, having the exact same syntax but it can also be used like recursion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fd7nd3wh4noa1banvhe9n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fd7nd3wh4noa1banvhe9n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, I started with a condition that states while the num is more than 0, print the num then decrements so once it hits 0 it'll break out of the loop and print "Happy New Year!!".&lt;/p&gt;

&lt;p&gt;As you can see the base case of the recursive solution and the while loop condition are basically the same the only difference is the way it's stated. The base case says "if the number is less than or equal to zero". And the while loop says " While the number is more than zero". Both need to hit zero in order for the breakout and both have to decrease the number to get there.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  side by side:
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fl9v9pnz1g9vxjrsjh0pq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fl9v9pnz1g9vxjrsjh0pq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's a more complex example of how they can be used w/ pseudo code to help break it down:
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fvimy0spsdsguwzyjbl0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fvimy0spsdsguwzyjbl0r.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fb1ks2w2pvenh6gnzdnh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fb1ks2w2pvenh6gnzdnh2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;I hope this comparison helped to give you a better understanding of recursion and how it can be used. Recursion is tricky to learn but it can allow you to break down big problems into smaller ones, and can sometimes even produce simpler solutions. If it helps try and think of it like a yoyo.&lt;/p&gt;

&lt;p&gt;Because this post is more of a comparison of while loops and recursion than explaining recursion, If you want to learn more about it here are a few links that really helped me:&lt;/p&gt;

&lt;p&gt;What is recursion - In Depth &lt;br&gt;
&lt;a href="https://youtu.be/6oDQaB2one8" rel="noopener noreferrer"&gt;https://youtu.be/6oDQaB2one8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recursion Crash Course:&lt;br&gt;
&lt;a href="https://youtu.be/lMBVwYrmFZQ" rel="noopener noreferrer"&gt;https://youtu.be/lMBVwYrmFZQ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stepping through recursion Fibonacci function:&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=zg-ddPbzcKM" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=zg-ddPbzcKM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(P.S. I still kinda hate it!)&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
