<?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>Forem: Heather</title>
    <description>The latest articles on Forem by Heather (@heatherhaylett).</description>
    <link>https://forem.com/heatherhaylett</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%2F335412%2Fa7609b96-6338-45a3-b0f9-52d182f7d0c4.jpeg</url>
      <title>Forem: Heather</title>
      <link>https://forem.com/heatherhaylett</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/heatherhaylett"/>
    <language>en</language>
    <item>
      <title>Easy React Project Set-Up</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Tue, 28 Jul 2020 17:04:01 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/easy-react-project-set-up-517c</link>
      <guid>https://forem.com/heatherhaylett/easy-react-project-set-up-517c</guid>
      <description>&lt;p&gt;You know what they say, taking the first step is the key to getting started. Easy as they are, there are a few steps to set up a new project. I put them all in one place so I no longer have to google the individual tasks each time. This post is focused on setting up a project using create-react-app. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a local React directory
&lt;/h3&gt;

&lt;p&gt;In your terminal run the following commands to use create-react-app, where &lt;em&gt;my-app&lt;/em&gt; is the name of your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
code my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Clean up the create-react-app files
&lt;/h3&gt;

&lt;p&gt;The files created in your new project require some clean up to have a fresh start.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open App.js and remove code between the header tags &lt;/li&gt;
&lt;li&gt;Open index.html and change the name and content as well as the text in title tag&lt;/li&gt;
&lt;li&gt;Delete react png files in the public directory&lt;/li&gt;
&lt;li&gt;&lt;em&gt;optionally insert your own favicon&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Delete everything in App.css&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Create a Github repository
&lt;/h3&gt;

&lt;p&gt;Click the &lt;strong&gt;new repository&lt;/strong&gt; button in GitHub and select a unique name. You don't need to initialize with a README.md if you used create-react-app&lt;br&gt;
create repository&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 4: Connect your repository to your local project
&lt;/h3&gt;

&lt;p&gt;Use the instructions &lt;em&gt;Push an existing repository from the command line&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;git remote add origin 'your_url_name'
git push -u origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Change Master to Main
&lt;/h3&gt;

&lt;p&gt;While this step is optional, I think it's important. &lt;a class="mentioned-user" href="https://dev.to/afrodevgirl"&gt;@afrodevgirl&lt;/a&gt;
 has created an excellent resource. &lt;/p&gt;

&lt;p&gt;Follow this post to change master to main &lt;br&gt;
&lt;a href="https://dev.to/afrodevgirl/replacing-master-with-main-in-github-2fjf"&gt;https://dev.to/afrodevgirl/replacing-master-with-main-in-github-2fjf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should now have a blank React canvas to begin developing. Five easy steps to start your React project!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Short Introduction to TypeScript</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Mon, 01 Jun 2020 05:37:00 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/short-introduction-to-typescript-2fih</link>
      <guid>https://forem.com/heatherhaylett/short-introduction-to-typescript-2fih</guid>
      <description>&lt;p&gt;TypeScript is an open-source language built upon JavaScript. If you have written code in JavaScript, that code is also TypeScript. The difference being that if you were to copy your JavaScript over into a TypeScript file, the TypeScript type-checker would most likely find that your code isn’t doing what you thought it was.&lt;/p&gt;

&lt;p&gt;JavaScript is a flexible programming language and allows variables to be reassigned to different data types which can result in type errors. TypeScript’s type-checker resolves this problem with an additional layer that utilizes a type-system language extension. The type-system language within TypeScript will check that data types have been properly assigned within code. &lt;/p&gt;

&lt;p&gt;Ready to learn more about TypeScript? Let’s look at what TypeScript adds to JavaScript, examples of writing TypeScript code, and finish with why programmers choose TypeScript. &lt;/p&gt;

&lt;h3&gt;
  
  
  Basics of TypeScript
&lt;/h3&gt;

&lt;p&gt;TypeScript is a statically typed language which means types are checked when the code is compiled. When a TypeScript file is initialized a configuration file will exist that defines how strict the type checker should be. Meaning, types in TypeScript are actually optional, but that can lessen the overall value of using TypeScript.&lt;/p&gt;

&lt;p&gt;What do I mean when the code is compiled? To run on the browser, at run time, TypeScript is converted to JavaScript with a compiler. The TypeScript compiler or 'tsc' is installed when TypeScript is installed via npm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --global typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another feature of TypeScript is type inference which means the language will infer what type you are assigning to a variable without being explicit. For example, in the snippet below, TypeScript will infer that myName is of the type ‘string’.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myName = ‘Heather’;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Write TypeScript
&lt;/h3&gt;

&lt;p&gt;As stated above, TypeScript is a type-system language meaning that there are rules as to how to construct variables, functions, etc. The examples below will cover a few of the types in TypeScript but not all.&lt;/p&gt;

&lt;h4&gt;
  
  
  Basic Types
&lt;/h4&gt;

&lt;p&gt;TypeScript has basic types similar to primitive data types in JavaScript. The following examples look at Boolean, Number, and String types.&lt;/p&gt;

&lt;p&gt;To declare and initialize a variable&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use a let or const statement &lt;/li&gt;
&lt;li&gt;variable name&lt;/li&gt;
&lt;li&gt;colon&lt;/li&gt;
&lt;li&gt;type &lt;/li&gt;
&lt;li&gt;assign a value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let isDog: boolean = true; 
let age: number = 8;
let name: string = “Captain”;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An interface names types that focus on the shape of a value. In this example we are requiring the passed in argument for the function ‘getName’ to have a property ‘name’.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface hasName {
    name: string;
}

function getName(dogObj: hasName) {
    console.log(dogObj.name);
}

let myDog = { name: “Captain”};
getName(myDog); // prints “Captain”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Functions in TypeScript
&lt;/h4&gt;

&lt;p&gt;When creating a function in TypeScript parameters can be given a type as well as the return value of 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;let dogOwner = function(owner: string, dog: string) =&amp;gt; string = function(
    owner: string,
    dog: string,
): string {
    return `{owner} belongs to {dog}`;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why Programmers Choose TypeScript
&lt;/h3&gt;

&lt;p&gt;While TypeScript may seem tedious at first, there are obvious advantages. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Self-documenting:&lt;/strong&gt; By using TypeScript you are essentially commenting your code to let other programmers know what the code is expecting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tooling:&lt;/strong&gt; IntelliSense helps with code completion and TypeScript improves this tool by defining types as you go. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Debugging:&lt;/strong&gt; As mentioned at the beginning of this post, JavaScript can be easily written with type errors which are not found until run time and a programmer has to figure out what is causing the problem. With TypeScript you'll know right away if an expected argument is the wrong type.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Cleaning up documentation, improving coding tools, and speeding up debugging should encourage any programmer to checkout TypeScript. As the language grows in popularity, it's worth having basic knowledge of the TypeScript language.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>4 Tips for Web Accessibility</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Sat, 23 May 2020 21:24:01 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/4-tips-for-web-accessibility-2ff4</link>
      <guid>https://forem.com/heatherhaylett/4-tips-for-web-accessibility-2ff4</guid>
      <description>&lt;p&gt;Driving a car, walking a flight of stairs, or watching a movie are activities people without a disability do without a second thought. These activities can present barriers to people living with a disability but can be overcome when steps are taken to provide accessibility. Similarly, the worldwide web needs to provide information that is accessible to all users, regardless of their ability to see, read, hear, or interact with a machine.&lt;/p&gt;

&lt;p&gt;Web accessibility is a practice focused on ensuring information from a website is accessible by all users. A barrier to information can be caused by a disability, physical or situational, or it may be socio-economic meaning that a user has limited bandwidth. &lt;/p&gt;

&lt;p&gt;Web accessibility should be considered by developers throughout the planning, design, and implementation of an application because everyone deserves to have access to information that is largely held on the worldwide web. &lt;/p&gt;

&lt;p&gt;In this post I’ll cover four ways to make a website more accessible. To illustrate these four tips I'll build a form to register dogs in a neighborhood. This form will incorporate each tip to create a website available for all users.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Clear Layout
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Helpful for:&lt;/strong&gt; screen readers&lt;/p&gt;

&lt;p&gt;People with visual ability can gain context by looking at a website and determining the order in which information is meant to be delivered. For users who have a visual disability or no sight use screen readers to interpret information. Screen readers describe the text and user-interface options to a user. &lt;/p&gt;

&lt;p&gt;If the DOM elements are not placed in an order that matches visual components, it can create a barrier for the user. In addition to the order, labels and headers should properly describe the content.&lt;/p&gt;

&lt;p&gt;Here we have our form for the neighborhood dog registry website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g4e0xYXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xkzf7qeb7gimjnbbbfcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g4e0xYXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xkzf7qeb7gimjnbbbfcu.png" alt="Neighorhood dog registry website"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The HTML looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r84JWnPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qa0r601dxf8gl6f4p4lf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r84JWnPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qa0r601dxf8gl6f4p4lf.png" alt="HTML for neighborhood dog registry"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The text starts at the top with an H1 tag that indicates a title followed by an h2 tag. Every input has a label describing the input and an input tag describing what type of input is expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Text Alternative
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Helpful for:&lt;/strong&gt; users with partial sight, color blindness, older users&lt;/p&gt;

&lt;p&gt;Interacting with a website involves text, images, buttons, and inputs. These interactions may use features such as color to indicate an action or missing information. For example if the input is required, the input may be highlighted red. For a user with partial sight or color blindness, this distinction might not be obvious. This problem can be solved with a text alternative. &lt;/p&gt;

&lt;p&gt;Adding a text indicator such as the keyword ‘required’ or an icon can let users know the input is required. Images should also incorporate text alternatives to describe the image to users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QiQT909D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yuhlzdfp4umw17z25mjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QiQT909D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yuhlzdfp4umw17z25mjv.png" alt="Red input box for required name input"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Users without a vision disability may be able to garner that the red box means it's required. For others, it's important that we have a text alternative. &lt;/p&gt;

&lt;p&gt;In our HTML we use the keyword 'required' which gives us a pop-up that states the input is required as well as prevents the form from being submitted. A screen reader will identify the input as required and translate to the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Non-Text Color Contrast
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Helpful for:&lt;/strong&gt; users with partial sight, older users, color blindness&lt;/p&gt;

&lt;p&gt;Brands put a lot of energy into making sure their product or service is unique and the color is a large part of marketing. If color contrast is overlooked in this process, a website can leave users with a visual disability unable to distinguish content on the page. &lt;/p&gt;

&lt;p&gt;The contrast ratio is the contrast in brightness between two colors. The minimum contrast a website should use is 4.5:1. For reference, white text on a white background has a ratio of 1:1. You can use a &lt;a href="https://webaim.org/resources/contrastchecker/"&gt;contrast checker&lt;/a&gt; like the one provided by webaim.com. Exceptions to the best practice for color contrast are large text (over 18pt), logotypes, or incidental text that isn't needed for context. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uylTMytS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yadc9txi8i79xot11nw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uylTMytS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yadc9txi8i79xot11nw6.png" alt="color contrast checker for white and blue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A color contrast checker will tell us what ratio our color contrast is. Now we can apply this color to our button and h2 header.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Keyboard Options
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Helpful for:&lt;/strong&gt; people with no vision, speech input software, scanning software, mobility impairments&lt;/p&gt;

&lt;p&gt;Without planning, a website can be created to only interact with mouse events meaning a user has to click on buttons to perform actions. Clicking, selecting, and moving items on the screen should be operable through a keyboard or an alternate keyboard allowing for hands-free interaction. A user should also be able to traverse DOM elements by using the up and down arrows on a keyboard.&lt;/p&gt;

&lt;p&gt;Using jQuery we can use both a click function and a keypress function to allow a user to submit a form by clicking the button or pressing enter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I21yNlup--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ifd0cz8tqkkavqtzwrsu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I21yNlup--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ifd0cz8tqkkavqtzwrsu.png" alt="jQuery function for click and keypress events"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we click the button or press enter, we get the corresponding message in the console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SBMLL2aD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vfburwho9w8k6k78jmkn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SBMLL2aD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vfburwho9w8k6k78jmkn.png" alt="console message for click and keypress"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building an Accessible Website
&lt;/h2&gt;

&lt;p&gt;Our end form now has&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear structure, with descriptive labels and headings&lt;/li&gt;
&lt;li&gt;Inputs with text alternatives stating information is required&lt;/li&gt;
&lt;li&gt;Color contrast with 4:5:1 ratio&lt;/li&gt;
&lt;li&gt;The ability to press enter to submit the form &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post only covered four ways that a website can be more accessible meaning there are numerous ways to make sure a website is created with all users in mind. It can be easy to forget to incorporate these practices when you are not living with a disability but the world wide web should not create any barriers to knowledge. &lt;/p&gt;

&lt;p&gt;If you have any suggestions on how to improve accessibility on a website, drop them in the comments!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources Used&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Web_accessibility"&gt;Web accessibility - wikipedia.org&lt;/a&gt;&lt;br&gt;
&lt;a href="https://webaim.org/resources/contrastchecker/"&gt;Contrast Checker - webaim.org&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3.org/WAI/WCAG21/Understanding/"&gt;W3.org&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to make a query with GraphQL
</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Sun, 17 May 2020 20:28:55 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/how-to-make-a-query-with-graphql-582b</link>
      <guid>https://forem.com/heatherhaylett/how-to-make-a-query-with-graphql-582b</guid>
      <description>&lt;p&gt;One of the most important skills you can learn as a developer is that you will never know everything. For me, it has been an immense relief and a realization that sparks excitement. You can never know everything because &lt;em&gt;there is always something new to learn&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I’ve been exploring different frameworks, services, and languages and I’ve come across discussions from other developers involving GraphQL. GraphQL is a querying language that exists between a client and a data source that receives requests from the client. In this post, I’ll dive into what exactly GraphQL is, how it compares to REST, terms to know and show an example of making a query.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is GraphQL?
&lt;/h2&gt;

&lt;p&gt;GraphQL is an open-source query language created by Facebook for APIs that can read or change data and alert a client to real-time updates. Known most widely for its structure, when you ask for data from the database, you tell GraphQL explicitly how to structure the data. Your query is then returned in the same format. This will make more sense when we get into the code examples. &lt;/p&gt;

&lt;p&gt;From reading the docs, one can gather that the creators of GraphQL are not attached to a specific use case or designation of purpose for GraphQL. They are very much open to developers collaborating and enhancing GraphQL.&lt;/p&gt;

&lt;p&gt;GraphQL consists of &lt;a href="https://github.com/graphql/graphql-spec"&gt;a type system, query language and execution semantics, static validation, and type introspection&lt;/a&gt;. We’ll explore terms to know more in-depth below.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does GraphQL compare to REST?
&lt;/h2&gt;

&lt;p&gt;REST is the standard for designing APIs at the moment. For an API or web services to be considered RESTful they need to apply the REST protocol, a client-server architecture for developing applications to be accessed over a network. Web services that use HTTP CRUD operations such as POST, GET, PUT, and DELETE are considered RESTful.&lt;/p&gt;

&lt;p&gt;When you want to query with a REST API you make a request to a specific endpoint. Queries can become complicated when you want to return information from many different endpoints all at once. GraphQL, on the other hand, has a single server that allows all requests to be fulfilled allowing for more flexible data queries. &lt;a href="https://www.howtographql.com/basics/1-graphql-is-the-better-rest/"&gt;How to GraphQL&lt;/a&gt; has a great visual example comparing REST and GraphQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  GraphQL Terms to Know
&lt;/h2&gt;

&lt;p&gt;I don’t cover &lt;em&gt;all&lt;/em&gt; GraphQL terms below, just the ones we will encounter in the query example at the end of this post.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schema:&lt;/strong&gt; describes to the client what information is available&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resolver:&lt;/strong&gt; client-side functions to get a response from GraphQL&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; defines data types used in GraphQL implementation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Field:&lt;/strong&gt; returns a specified type of data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query:&lt;/strong&gt; root level type (defined above) similar to GET request using REST&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Argument:&lt;/strong&gt; query parameter to get specific data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Make a Query with GraphQL
&lt;/h2&gt;

&lt;p&gt;Say we have a database that stores information about dogs in our neighborhood. The database has a dog table that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aBBbrJ14--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yxuh58n2qxomeid8sl1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aBBbrJ14--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yxuh58n2qxomeid8sl1h.png" alt="database with dog info"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The application we're programming should be able to pull information out about each dog. We can use a GraphQL query to get this information.&lt;/p&gt;

&lt;p&gt;The first step is to create a schema. The schema will define our types and tell the client what information the query can access. Often, your GraphQL schema will look similar to your database schema, but you can make some customizations.&lt;/p&gt;

&lt;p&gt;We create a type with the keyword &lt;em&gt;type&lt;/em&gt; and fields that have a specific data type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Dog {
  id: String
  name: String
  age: Int
  favTreat: String
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to create a &lt;em&gt;Query&lt;/em&gt; type that is an entry point to our type system.&lt;/p&gt;

&lt;p&gt;You'll notice we've given an argument to the query (id: String). This means we will pass in a specific id and get the dog who matches with that id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Query {
  dog(id: String): Dog
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can use a query to get information. We specify all the fields that we want the query to return, name, age, and favTreat.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query getDog {
  dog(id: ${id}) {
    name
    age
    favTreat
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can use the query 'getDog' with a specific id. We don't have to ask for everything - name, age, and favTreat - but in this example we want all the information.&lt;/p&gt;

&lt;p&gt;Notice how our return is structured the same as our query, pretty neat!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query getDog {
  dog(id: "1") {
    name
    age
    favTreat
  }
}

// returns

{
  "dog": {
    "name": "Chewy"
    "age": 4
    "favTreat": "Bacon"
  }
}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Programming with GraphQL
&lt;/h2&gt;

&lt;p&gt;I've only just started playing around with GraphQL but I'm already enjoying the flexibility it provides when asking for data. I'm going to continue learning more about GraphQL especially as it seems to be a technology that will be beneficial to have going forward. &lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>graphql</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Differentiate UX and UI</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Sat, 09 May 2020 00:12:52 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/how-to-differentiate-ux-and-ui-4fh8</link>
      <guid>https://forem.com/heatherhaylett/how-to-differentiate-ux-and-ui-4fh8</guid>
      <description>&lt;p&gt;I’m in the last segment of my immersive software engineering boot camp in which the next step is to enter the job hunt. Entering the program, I had no comprehension of the skills that I would be exiting with. To be honest, I knew almost nothing about computer science or what software engineers even did. &lt;/p&gt;

&lt;p&gt;I like to point out that I thought maybe someday (throughout the span of my career) it might be cool to learn everything that is presented in all six learning modules on freecodecamp.org. Well, my program covered &lt;strong&gt;all of them&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That being said, I’ve taken in a lot of information and explored many facets of development. Now that I’m closer to applying to jobs I’m exploring what type of position I might be most interested in. There are the obvious distinctions between front-end and back-end, but there also seem to be more specific titles as well. &lt;/p&gt;

&lt;p&gt;A frequent title I see is &lt;em&gt;UI developer&lt;/em&gt;, &lt;em&gt;UX designer&lt;/em&gt;, or some combination of the two. Not knowing exactly what either UX or UI is I decided to parse them out. In this post, I’ll define what UX and UI are, how they differ, and how they work together. &lt;/p&gt;

&lt;h2&gt;
  
  
  User Experience - UX
&lt;/h2&gt;

&lt;p&gt;User experience, or UX, is a design technique that focuses on a user's feelings during and after an interaction with a product. The emphasis here is on &lt;em&gt;feel&lt;/em&gt;. A UX designer puts themself in a user’s shoes when thinking about how a product should work. These questions can range from asking, ‘how does the user feel?’ to ‘how easy is it to do &lt;em&gt;blank&lt;/em&gt;?’.&lt;/p&gt;

&lt;p&gt;The UX designer does not focus on the look of a product but is empathic to the user. It is common for a UX designer to not be involved with any coding. Their work may be done surveying potential customers and analyzing data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common UX job descriptions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interpret data to create solutions&lt;/li&gt;
&lt;li&gt;Tell a story focused on end-user&lt;/li&gt;
&lt;li&gt;Use design research methods&lt;/li&gt;
&lt;li&gt;Define and clarify best practices &lt;/li&gt;
&lt;li&gt;Plan and architect &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  User Interface - UI
&lt;/h2&gt;

&lt;p&gt;User interface, or UI, is all about how a product looks and functions. There are many types of UI and the one I will focus on in this post is graphical user interface. &lt;/p&gt;

&lt;p&gt;UI developers are often creative types. They think through how buttons and user inputs should interact as well as adhering to style guides via typography and color schemes. A UI developer considers how a user will interact with a product and work to make the product intuitive and logical&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common UI job descriptions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Execute visual design concepts&lt;/li&gt;
&lt;li&gt;Adhere to style guides&lt;/li&gt;
&lt;li&gt;Experience with HTML, CSS&lt;/li&gt;
&lt;li&gt;Attention to detail&lt;/li&gt;
&lt;li&gt;Build custom tools&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Separating UX and UI
&lt;/h2&gt;

&lt;p&gt;As we can see from the above descriptions, UX and UI are different parts of the design process. UX happens before any tangible product and focuses on the user. UI, on the other hand, is an iterative process that takes place as a product is built. A UI developer's main concern is how a product looks.&lt;/p&gt;

&lt;p&gt;I like to think of the user story’s role in this process. When we write a user story we describe what a user can do. The user experience can be determined as we walk through a product and identify user actions. The user story can then go on to define what buttons should exist and where components should live for intuitive use of the product.&lt;/p&gt;

&lt;p&gt;While user experience and user interface are unique processes they are most certainly intertwined. UX designers create wireframes or prototypes then UI developers create an aesthetically pleasing covering. One can not excel without the other. &lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing Between UX and UI
&lt;/h2&gt;

&lt;p&gt;After defining UX and UI I think both roles interest me. I enjoy being creative and crafting how an application will look. I'm equally concerned with the ease of use and if a user likes interacting with my application. I think I will continue to strengthen my HTML and CSS skills in the chance that I decide to pursue a UI specific role.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources Used&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://xd.adobe.com/ideas/process/ui-design/ui-vs-ux-design-understanding-similarities-and-differences/"&gt;What are the Similarities &amp;amp; Differences Between UI Design &amp;amp; UX Design?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://careerfoundry.com/en/blog/ux-design/the-difference-between-ux-and-ui-design-a-laymans-guide/#1-whats-the-difference-between-ux-and-ui-design"&gt;The Difference Between UX And UI Design - A Layman’s Guide&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/User_experience_design"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;

</description>
      <category>design</category>
      <category>codenewbie</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Learn the Basics of Websocket with Me</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Sun, 03 May 2020 21:02:44 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/learn-the-basics-of-websocket-with-me-41c1</link>
      <guid>https://forem.com/heatherhaylett/learn-the-basics-of-websocket-with-me-41c1</guid>
      <description>&lt;p&gt;I recently worked on two applications where my team wanted to implement an instant message feature allowing users to communicate in real-time. None of us had worked with WebSockets before so we decided it would be a great learning opportunity. Now that I’ve finished those projects I’m doing that thing where you go back and learn the basics of the tool you were using. While I was creating a chat feature with WebSockets, I definitely didn’t understand what magic was happening so I’m excited to explore in this blog post. &lt;/p&gt;

&lt;p&gt;In this post, I’ll cover a basic review and history of how data is transferred over the web to create the webpage we see. Then I’ll dive into what WebSockets are and finish up with a demo I reproduced to help cement my knowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reviewing Client-Server Connections
&lt;/h3&gt;

&lt;p&gt;As a user, when I go to a webpage I expect to see information and links I can click on or inputs where I can enter information. I move from page to page or receive new information based on an action that I took. Everything that is happening on the webpage is a result of the user doing something. Making a request and receiving a response is the basic setup of how a client communicates with a server. The server is reacting to a request from the client and historically, the client has always had to initiate the process. &lt;/p&gt;

&lt;p&gt;HTTP, or Hypertext Transfer Protocol, is the protocol for transferring data through the client/server request and response model. HTTP can only allow a client to initiate a request to the server, a server cannot send information to the client without being asked. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ably.io/concepts/websockets"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yT100Ed6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y53tcmws53k3tupbnf9m.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In relation to how information shows up on a webpage, if we want to display data from the server we need to ask for it, then the server sends it to the client, and the client has to show the new data by accepting the information and refreshing the page. This back and forth of requests and responses can slow down an application. So what if there was an open connection between the client and server to continuously send and receive data? Websockets achieve this functionality for us.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining Websockets
&lt;/h3&gt;

&lt;p&gt;Real-time web is when a client receives data as soon as it’s published and doesn’t need an update to get that response. Websocket is a protocol that keeps the connection between client and server open for persistent data exchange. WebSockets are a fairly new technology but quickly becoming an industry standard. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ably.io/concepts/websockets"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---KyPPmt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8qw2u6zsd51n1veuizcw.png" alt="bi-directional"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I mentioned earlier that I had used WebSockets for an instant messaging feature. Websocket data transfer is great for short messages, news updates, etc. really any kind of data that changes frequently. That being said, it’s important to note that WebSockets will not replace HTTP in your server rather it enhances HTTP protocol.&lt;/p&gt;

&lt;p&gt;To create the WebSockets bi-directional connection between client and server, the client must first initiate a request to the server with what is known as a &lt;strong&gt;WebSocket handshake request&lt;/strong&gt;. This handshake request contains an upgrade WebSocket header telling the server to switch to bi-directional protocol.&lt;/p&gt;

&lt;p&gt;In each project, I used a different library for writing features that utilize WebSockets. The services my team used were &lt;a href="//socket.io"&gt;Socket.io&lt;/a&gt; and &lt;a href="https://pusher.com/"&gt;Pusher&lt;/a&gt;. I didn’t have a preference between the two as I mentioned before I wasn’t totally sure of what was happening under the hood. I just knew they were making neat things happen in my application. As I continue building applications, I’ll be interested to further explore the capabilities of both. &lt;/p&gt;

&lt;h3&gt;
  
  
  Build a Websocket Connection
&lt;/h3&gt;

&lt;p&gt;I followed a demo from &lt;a href="https://www.ably.io/concepts/websockets"&gt;ably.io&lt;/a&gt; that me to understand the process of establishing a WebSocket connection.&lt;/p&gt;

&lt;p&gt;The first step is to construct a WebSocket using the &lt;strong&gt;new WebSocket()&lt;/strong&gt; method. This demo uses (websocket.org)[websocket.org] to host a WebSocket Echo server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // create a new WebSocket
  const socket = new this.WebSocket('ws://echo.websocket.org');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we use &lt;strong&gt;onopen&lt;/strong&gt; to open the WebSocket connection&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // show a connected message when the WebSocket is opened
  socket.onopen = function(event) {
    socketStatus.innerHTML = 'Connected to: ' + event.currentTarget.url;
    socketStatus.className = 'open';
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To send a message to the server we use &lt;strong&gt;send&lt;/strong&gt; and add it to our chat box for other users to see.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  socket.send(message);
  // add message to list of messages
  console.log('sent from client: ' + message);
  messagesList.innerHTML += '&amp;lt;li class="sent"&amp;gt;&amp;lt;span&amp;gt;Sent:&amp;lt;/span&amp;gt;' + message + '&amp;lt;/li&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, we need to tell the server to fire an event when the message is received with &lt;strong&gt;onmessage&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;  socket.onmessage = function(event) {
    const message = event.data;
    console.log('received: ' + message);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the page it looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KpzTpolO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/emil968qtjz5ke92jc35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KpzTpolO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/emil968qtjz5ke92jc35.png" alt="WebSocket demo on page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources Used&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://pusher.com/websockets"&gt;What are WebSockets?&lt;/a&gt; from pusher.com&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=8ARodQ4Wlf4"&gt;A Beginner's Guide to WebSockets&lt;/a&gt; from freeCodeCamp&lt;br&gt;
&lt;a href="https://www.ably.io/concepts/websockets"&gt;WebSockets&lt;/a&gt; from ably.io&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>mySQL vs MongoDB - What's the Difference?</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Sun, 05 Apr 2020 18:46:54 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/mysql-vs-mongodb-what-s-the-difference-4p9c</link>
      <guid>https://forem.com/heatherhaylett/mysql-vs-mongodb-what-s-the-difference-4p9c</guid>
      <description>&lt;p&gt;In conversation, mySQL and MongoDB are often referred to as databases. While calling them a database is not wrong, the titles actually point to software that &lt;em&gt;creates&lt;/em&gt; databases. A database management system, DBMS, is an interface that handles data from an end-user or application. &lt;/p&gt;

&lt;p&gt;In this post, we’ll discuss the key differences between mySQL and MongoDB as well as point out how they are similar. We’ll also look at making a query in both systems during our comparison. Finally, we’ll go over some questions to ask when deciding which system is the best fit for your application or organization. &lt;/p&gt;

&lt;h3&gt;
  
  
  Checking Out the Differences
&lt;/h3&gt;

&lt;p&gt;There are many differences between mySQL and MongoDB, but the overarching distinction is the use of SQL. SQL, or structured query language, is a declarative programming language. We call mySQL a relational database management system because it uses SQL. SQL maintains data in the form of tables with rows and columns. The &lt;strong&gt;row&lt;/strong&gt; in a table will hold &lt;strong&gt;values&lt;/strong&gt; that are organized by &lt;strong&gt;columns&lt;/strong&gt; which tell the row what &lt;strong&gt;specific type of information&lt;/strong&gt; it holds. &lt;/p&gt;

&lt;p&gt;MongoDB, on the other hand, is a NoSQL database management system.  NoSQL stands for &lt;em&gt;not only&lt;/em&gt; SQL. This means that MongoDB doesn’t use tables to store data, but rather it is a document-oriented database. A MongoDB database that uses NoSQL will look more like an object that contains key-value pairs. &lt;/p&gt;

&lt;p&gt;Choosing whether a SQL or NoSQL database is &lt;em&gt;better&lt;/em&gt; can only be done subjectively based on the needs of your application. A SQL database management system like mySQL is structured specifically and organizes data rigidly. For an application storing bank transactions, this type of organization is critical. As a NoSQL database management system, MongoDB offers more flexibility and can be thought of as a folder that holds many files. These files can have a mixture of information that doesn’t need to be specifically organized. &lt;/p&gt;

&lt;h3&gt;
  
  
  Similarities Between Systems
&lt;/h3&gt;

&lt;p&gt;When storing data, it makes sense that mySQL and MongoDB would do some of the same tasks. Each will need a way to add, remove, and change data as well as access data to perform an action. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overall Organization&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mySQL: Tables&lt;/li&gt;
&lt;li&gt;MongoDB: Collection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Linking Information&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mySQL: Primary key&lt;/li&gt;
&lt;li&gt;MongoDB: _id&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to Store Data&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mySQL: Row &lt;/li&gt;
&lt;li&gt;MongoDB: BSON document&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Combine Data&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mySQL: Join &lt;/li&gt;
&lt;li&gt;MongoDB: Embed/Link&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Perform an Action on Stored Data&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mySQL: Group by&lt;/li&gt;
&lt;li&gt;MongoDB: Aggregation &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Making a Query
&lt;/h3&gt;

&lt;p&gt;Earlier we discussed a major difference between mySQL and MongoDB which is the use of the SQL language. When we look at the two styles of making a query, you will notice that mySQL looks like plain English. The use of means we don’t have to describe the control flow, it knows what to do. In contrast, MongoDB looks more like a JavaScript with the use of dot notation and methods. &lt;/p&gt;

&lt;p&gt;Here are some basic query commands to demonstrate the difference between SQL and NoSQL:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MySQL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To start:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mysql -uroot&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Create database:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CREATE DATABASE database name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Create table:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CREATE TABLE table name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Add:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;INSERT INTO table name (data) VALUES&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Show all tables:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SHOW TABLES&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Describe how a table is organized:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DESCRIBE table name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;List what’s inside a table:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SELECT * FROM table name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In MySQL we create a database and then we create tables to hold the data. When we insert data, the values need to match our column value type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To start:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mongo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Create a database:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use Database_Name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Create a collection:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;db.createCollection(collectionName)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Add a value:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;db.collectionName.insertOne( {
…. Data key-value pair
})&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Show a collection:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;db.collectionName.find.pretty( )&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In MongoDB we create a database and then we create a collection to store data. We create the key-value pair when we insert data, no need to have a specific type of information.&lt;/p&gt;

&lt;h3&gt;
  
  
  mySQL or MongoDB? Questions to Ask
&lt;/h3&gt;

&lt;p&gt;Now that you have an idea of how mySQL and MongoDB function you can start to determine which database management system is the right choice for your application or organization. The differences between the two will cause you to ask yourself a few questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. How big is your data and how is it structured?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The volume of your data will affect how quickly you are able to access information and your ability to maintain it. As a document-oriented database, MongoDB allows you to store data in one place without defining types of information. This is beneficial for large, unstructured data. If you have very specific data, organized in a certain way, mySQL will provide a structured database. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Is your data unchanging or are you making frequent updates?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your data is consistent and unchanging a relational database like mySQL helps keep information clearly defined. Document-based databases like MongoDB allow more flexibility when it comes to altering data. &lt;/p&gt;

&lt;p&gt;In the end, there is no best choice, there’s only a better choice when it comes to the specific needs of your database. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources Used&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.analyticbridge.datasciencecentral.com/profiles/blogs/comparing-mongodb-with-mysql"&gt;Comparing MongoDB with MySQL&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.upwork.com/hiring/data/sql-vs-nosql-databases-whats-the-difference/"&gt;SQL vs. NoSQL Databases: What’s the Difference?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=Ke4G-c94VBM"&gt;MySQL vs MongoDB&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to Render a List with React</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Mon, 30 Mar 2020 00:18:47 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/how-to-render-a-list-with-react-5988</link>
      <guid>https://forem.com/heatherhaylett/how-to-render-a-list-with-react-5988</guid>
      <description>&lt;p&gt;React is a javascript library used to design the user interface on the front-end of an application. Just like any library there are unique processes for using the language. One such process is rendering a list. Developers interact with lists frequently whether it’s a list of users, items to add to a table, or any kind of data. &lt;/p&gt;

&lt;p&gt;In this post we’ll discuss how React renders html to the page, I’ll show some examples of how to render a list in React, and we’ll cover the importance of using unique identifiers.&lt;/p&gt;

&lt;h3&gt;
  
  
  React Rendering Basics
&lt;/h3&gt;

&lt;p&gt;When we are looking at an application what we see is referred to as the DOM, or document object model. To get the data we want to display on the DOM we use a render method. The render method takes data and returns what will be displayed on the DOM. React is built from elements that are updated with React DOM.&lt;/p&gt;

&lt;p&gt;Here's how you would use ReactDOM.render( ).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uCfPYvnA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b44ex6ia926g5fa43kio.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uCfPYvnA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b44ex6ia926g5fa43kio.png" alt="ReactDOM.render"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React has an ideology when it comes to rendering the DOM. In React, updates are meant to happen efficiently and only when necessary. To accomplish this, Reach utilizes what’s known as the virtual DOM. The virtual DOM is a concept that there is a representation of the UI stored in memory where changes can be made temporarily before rendering the real DOM. When a change is made to update the DOM in react, the virtual DOM changes first. Then the virtual DOM compares itself to the previous version held in memory. React will check to see what objects have changed. Finally, those objects change on the real DOM and those objects only. &lt;/p&gt;

&lt;p&gt;Think of the virtual DOM as a blueprint that makes for quick updating. Understanding this concept will help us later when we discuss unique attributes as they pertain to rendering a list in React.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Render a List in React
&lt;/h3&gt;

&lt;p&gt;When we want to show a list of items in our application they will have the same formatting. If the format of an element can be repeated, then we should create a dynamic way to render it to the page. In JavaScript when we want to repeat an action, we use loops. To render a list in React we can use a higher-order function to iterate over data and display it on the page.&lt;/p&gt;

&lt;p&gt;The first file contains our data which is an array of objects. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BMjoUCLy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jc61no57b97xmrukeglk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BMjoUCLy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jc61no57b97xmrukeglk.png" alt="rose family"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In another file, we have a Character component where we create a CharacterList component. In that component, we want to access the objects inside of our roseFamily array. To accomplish that we use the array.map method and set a property of character to each object. We also create a key property set to the id property inside each object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WUusgcGF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mmbn4lz1jc5fltopgjjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WUusgcGF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mmbn4lz1jc5fltopgjjv.png" alt="loop over data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside of our CharacterList file, we determine what data will be displayed for each element of the list. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0o_w2B3J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w4noj5p9p4due9jiqxzs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0o_w2B3J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w4noj5p9p4due9jiqxzs.png" alt="access each element"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Keys
&lt;/h3&gt;

&lt;p&gt;Using React, if you render a list to the page, you may encounter a warning: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;'Each child in a list should have a unique "key" prop'&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N9r--tf7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u3wof1fhldpprt2577a6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N9r--tf7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u3wof1fhldpprt2577a6.png" alt="key warning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This warning is pointing to the fact that your elements do not have a key property that is assigned to a unique value. Having a key property is important due to the way React renders Html to the page. Previously in this post, I covered how React renders an element if and only if they change. When we render a list to the page, React stores information about each item. Then if we make a change to the list such as adding or removing, React will update the list accordingly.  To update the list, React is given a key as a unique identifier, to check if it exists or not and takes action based on that data. &lt;/p&gt;

&lt;p&gt;Having a key property on your list allows React to render the list quickly and efficiently. You can use any unique identifier such as an id property or something like the last name if you know there won’t be any duplicates. Adding a key may require you to revisit your data and include an identifier. Keep in mind that 'key' is a special prop in React and cannot be accessed via this.props.key.&lt;/p&gt;

&lt;h3&gt;
  
  
  Things to Remember
&lt;/h3&gt;

&lt;p&gt;React is known for its ability to build complex user interfaces with components that can change often. Using the virtual DOM to compare changes so that only items that have been modified are changed on the real DOM is one of the reasons for a smooth user interface. For this rendering function to work with lists, it’s important to include a key that is a unique identifier. &lt;/p&gt;

&lt;p&gt;Rendering a list in React is easy with common JavaScript knowledge of higher-order functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Resources Used
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/rendering-elements.html"&gt;Rendering an Element into the DOM - React Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://reactjs.org/docs/lists-and-keys.html"&gt;Lists and Keys - React Docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>What are ES6 Classes?</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Sun, 22 Mar 2020 20:55:46 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/what-are-es6-classes-45ii</link>
      <guid>https://forem.com/heatherhaylett/what-are-es6-classes-45ii</guid>
      <description>&lt;p&gt;The great thing about programming is that the craft is ever-evolving. There is always something new to learn and ways to improve code. JavaScript also evolves as a language, introducing features that upgrade the language or fix deficiencies. This post will explore one such feature, ES6 Classes. &lt;/p&gt;

&lt;h4&gt;
  
  
  What is ECMAScript 6?
&lt;/h4&gt;

&lt;p&gt;ECMAScript 6, also known as ES6 is version 6 of the ECMA Script programming language. It provides new features for improving the language and writing cleaner code. Some aspects of ES6 are convention such as the variables &lt;strong&gt;let&lt;/strong&gt; and &lt;strong&gt;const&lt;/strong&gt;, while features like arrow functions have been widely adopted but aren't always the norm. Other parts of ES6 are less explored but are worth diving into.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is Object-Oriented Programming?
&lt;/h4&gt;

&lt;p&gt;A very brief definition of object-oriented programming (OOP) is that it is programming using self-contained code to create applications. TechTarget.com describes OOP as &lt;a href="https://searchapparchitecture.techtarget.com/definition/object-oriented-programming-OOP"&gt;"a programming language model that organizes software design around data, or objects, rather than functions and logic."&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;JavaScript is an object-oriented programming language and builds applications with objects. Objects allow us to use inheritance, polymorphism, and encapsulation. &lt;/p&gt;

&lt;h4&gt;
  
  
  What is a class?
&lt;/h4&gt;

&lt;p&gt;In JavaScript, if we want to create objects that have the same properties and methods we use constructor functions. A constructor function acts as a recipe to build objects over and over.&lt;/p&gt;

&lt;p&gt;In other languages, the recipe for creating similar objects is called a class. &lt;a href="https://en.wikipedia.org/wiki/Class_(computer_programming)"&gt;“In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods).”&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In other words, a class is a data type that must be defined before an object is created.&lt;/p&gt;

&lt;h4&gt;
  
  
  Does Javascript have class?
&lt;/h4&gt;

&lt;p&gt;Javascript doesn’t have classes, as mentioned above, JavaScript uses constructor functions to repeat code to create objects. With ES6 JavaScript has attempted to create something similar to classes at least by the way it looks and acts. &lt;/p&gt;

&lt;p&gt;While developers are quick to point out that ES6 classes are syntactic sugar, the javascript.info website disputes this claim. They argue classes are functions 'labeled' by a special internal property making the ES6 class more than a syntactic feature.&lt;/p&gt;

&lt;p&gt;ES6 class is an object constructor function that uses the keyword &lt;strong&gt;class&lt;/strong&gt; to declare the function and the &lt;strong&gt;constructor&lt;/strong&gt; keyword used inside the function to add a new property. Methods are also included in the code body and do not use the &lt;em&gt;function&lt;/em&gt; keyword.&lt;/p&gt;

&lt;h4&gt;
  
  
  ES6 Class Implementation
&lt;/h4&gt;

&lt;p&gt;We use the ES6 Class instantiation patter much like the pseudoclassical pattern. Let's take a look at how we would create an ES6 class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MOqztkFc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hkatji3v5u7ft90y4hf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MOqztkFc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hkatji3v5u7ft90y4hf2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The class keyword creates a new function that we name Pet. It's convention to use capital letters for constructor function declarations. Inside of that function is our constructor. We have two properties &lt;strong&gt;name&lt;/strong&gt; and &lt;strong&gt;nickname&lt;/strong&gt; and an &lt;strong&gt;eat&lt;/strong&gt; method. Later on when we want to create a new instance of our object, we use the ‘new’ keyword. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NNspJApm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6bz0n76w81ak2f2y34ax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NNspJApm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6bz0n76w81ak2f2y34ax.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we set myPet to a new instance of Pet passing it a &lt;strong&gt;name&lt;/strong&gt; and &lt;strong&gt;nickname&lt;/strong&gt; argument. We can call &lt;strong&gt;eat&lt;/strong&gt; passing in &lt;em&gt;trash&lt;/em&gt; as an argument and receive the expected console log value back.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using ES6 Classes
&lt;/h4&gt;

&lt;p&gt;ES6 Classes were introduced as an instantiation pattern for constructor functions and made to look and work like a class that is found in other programming languages. While not required, using ES6 features make for clean and readable code. It also allows you to use other enhancements only available when using ES6.&lt;/p&gt;

&lt;p&gt;My opinion is that programmers who write in JavaScript will benefit from learning to implement in ES6 in their code and will be better prepared when the next update is released. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources for Research&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes"&gt;Defining Classes - MDN&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model"&gt;Class-based vs. prototype-based languages - MDN&lt;/a&gt;&lt;br&gt;
&lt;a href="https://searchapparchitecture.techtarget.com/definition/object-oriented-programming-OOP"&gt;object-oriented programming (OOP)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>es6</category>
    </item>
    <item>
      <title>Beginners Guide: Hash Tables</title>
      <dc:creator>Heather</dc:creator>
      <pubDate>Mon, 16 Mar 2020 01:41:45 +0000</pubDate>
      <link>https://forem.com/heatherhaylett/how-to-handle-hash-table-collisions-with-map-m94</link>
      <guid>https://forem.com/heatherhaylett/how-to-handle-hash-table-collisions-with-map-m94</guid>
      <description>&lt;p&gt;As humans, we associate two concepts, ideas, or values with a definition. For example, Heather is a name. I can then say, 'my name is Heather'. Another way to write this association might be &lt;strong&gt;Name: Heather&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In programming, we call this a &lt;strong&gt;key-value pair&lt;/strong&gt;. Key values pairs are used when we want to store a value and then reference that value by a key name that we give it.&lt;/p&gt;

&lt;p&gt;In JavaScript we use objects to store key-value pairs. To make an object in JavaScript we can simply use curly braces {}. Objects were written into JavaScript for use. But how were they created? The &lt;strong&gt;hash table data structure&lt;/strong&gt; is the foundation or blueprint for JavaScript objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hash Table Data Structures
&lt;/h3&gt;

&lt;p&gt;A hash table is a data structure that associates values with a label(what we refer to as a key in objects). These label value pairs are stored in a table of a predetermined length. The storage table is an array that contains another storage element at each index. This element is referred to as a bucket. &lt;/p&gt;

&lt;p&gt;This post will show how you can use JavaScript ES6 Map object as the bucket storage container. Before we can talk about storing label value pairs in a bucket, we need to go over how they are assigned to a numerical index.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hashing Functions
&lt;/h3&gt;

&lt;p&gt;To store a value in our hash table we need to place it at an index in our storage array. The number that determines the index will come from &lt;em&gt;hashing&lt;/em&gt; our label using a hashing function. A hashing function takes two inputs, any data type, and a number. The number is the length of our hash table as the function can only return numbers as long as the length of the array. &lt;/p&gt;

&lt;p&gt;Do not worry about needing to know how to create a hash function. This &lt;a href="https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed" rel="noopener noreferrer"&gt;Software Engineering Stack Exchange&lt;/a&gt; discusses various hashing functions and their desirability. A preferred hashing function will provide speed and limit the possibility of collisions.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;There is a possibility of getting two keys that hash to the same index which is called a collision. Collisions can slow down your lookup methods and should be avoided.&lt;/em&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  Example of a hashing function:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const hash = (key, size) =&amp;gt; {
  let hashedKey = 0;

  for(let i = 0; i &amp;lt; key.length; i++){
    hashedKey = key.charCodeAt(i);
  }

  return hashedKey % size;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating a Hash Table with Map
&lt;/h3&gt;

&lt;p&gt;Let's walk through the steps of implementing a hash table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class HashTable {
  constructor() {
    this.size = 20;
    this.storage = Array(this.size);

    for(let i = 0; i &amp;lt; this.storage.length; i++){
      this.storage[i] = new Map();
    }

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

&lt;/div&gt;



&lt;p&gt;Here we create a hash table using ES6 instantiation pattern. Notice &lt;strong&gt;this.size&lt;/strong&gt; is hardcoded as hash tables have a pre-determined length. We set our storage array &lt;strong&gt;this.storage&lt;/strong&gt; to the size property. We then loop through our storage array and create a &lt;strong&gt;bucket&lt;/strong&gt; at each index which will be a new instance of Map.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Map object was introduced with ES6 and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" rel="noopener noreferrer"&gt;iterates its elements in insertion order&lt;/a&gt;. Map also stores key value pairs.&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;insert(key, value) {
      let idx = hash(key, this.size);
      this.storage[idx].set(key, value);
  }

  remove(key) {
    let idx = hash(key, this.size);
    let deleteKey = this.storage[idx].delete(key);
    this.storage[idx].delete(key);
    return deleteKey;
  }

  search(key) {
    let idx = hash(key, this.size);
    return this.storage[idx].get(key);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hash tables have three main methods, &lt;strong&gt;insert&lt;/strong&gt;, &lt;strong&gt;remove&lt;/strong&gt;, and &lt;strong&gt;search&lt;/strong&gt;. Our hash function is used for all three methods. This is because when we insert a key-value pair we need a number and when we give a hash table a key to look up or delete it needs to hash the key and use the number to find the value. Notice &lt;strong&gt;set&lt;/strong&gt;, &lt;strong&gt;get&lt;/strong&gt;, and &lt;strong&gt;delete&lt;/strong&gt; in our implementation code, they are built-in methods of the Map object.&lt;/p&gt;

&lt;h4&gt;
  
  
  Hash Table in Action
&lt;/h4&gt;

&lt;p&gt;We create a new hash table called nolaFoodieBucketList and assign a &lt;strong&gt;label&lt;/strong&gt; of food items to try to a &lt;strong&gt;value&lt;/strong&gt; of places to have them.&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%2Fi.imgur.com%2F3yoqeZY.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%2Fi.imgur.com%2F3yoqeZY.png" alt="create"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we log the hash table we can see all the label-value pairs have gone to various buckets. We can also see collisions at bucket 1.&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%2Fi.imgur.com%2FsWMyDGx.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%2Fi.imgur.com%2FsWMyDGx.png" alt="log"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we search for 'hurricane' we receive 'Pat O'Brien's' back, even though there were multiple label-value pairs at bucket 1.&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%2Fi.imgur.com%2FGMXU74K.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%2Fi.imgur.com%2FGMXU74K.png" alt="search"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Time Complexity
&lt;/h3&gt;

&lt;p&gt;Hash tables are a favored data structure because on average they provide a time complexity of constant time for insertion, deletion, and search. Hash tables don't need to look through every bucket for a value because it is associated with a key. All the hash table will need is the key to directly find its value. The time complexity of constant time is average due to the possibility of multiples key-value pairs hashing to the same bucket.&lt;/p&gt;

&lt;p&gt;Time complexity makes hash tables a preferred choice for data structure when code requires a fast run time to search through data. &lt;/p&gt;

&lt;h4&gt;
  
  
  Research Resources
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=QuFPIZj55hU" rel="noopener noreferrer"&gt;@beiatrix YouTube channel&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.hackerearth.com/practice/data-structures/hash-tables/basics-of-hash-tables/tutorial/" rel="noopener noreferrer"&gt;Basics of Hash Tables&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
