<?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: joespaf</title>
    <description>The latest articles on Forem by joespaf (@joespaf).</description>
    <link>https://forem.com/joespaf</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%2F2147285%2F85a48136-2152-4315-b16f-f5f9cf477f8e.png</url>
      <title>Forem: joespaf</title>
      <link>https://forem.com/joespaf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/joespaf"/>
    <language>en</language>
    <item>
      <title>Magic: The Gathering Explained With JavaScript Classes</title>
      <dc:creator>joespaf</dc:creator>
      <pubDate>Mon, 13 Oct 2025 06:58:43 +0000</pubDate>
      <link>https://forem.com/joespaf/magic-the-gathering-explained-with-javascript-classes-3d2</link>
      <guid>https://forem.com/joespaf/magic-the-gathering-explained-with-javascript-classes-3d2</guid>
      <description>&lt;p&gt;Magic: The Gathering is a classic trading card game, with millions of players playing every day. It's a game with fantastic depth, built with systems allowing players to play in unexpected and exciting ways. In Commander, one of the most popular formats, four players fight in a free for all with 100 card decks, each of which has no repeating cards (with the notable exception of basic lands). To someone unfamiliar with Magic, this might sound like an outrageous amount of information; with up to 400 different cards between all the players, how could they possibly be expected to understand how to play? Are they supposed to simply memorize the over 27,000 Magic cards in existence? What sort of maniac would want to play a game like that?&lt;/p&gt;

&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%2Fvmhb8wpuyg9wzkkhs4ln.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%2Fvmhb8wpuyg9wzkkhs4ln.png" alt=" " width="672" height="936"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fortunately, Magic's cards are designed with strict parameters and formatting, allowing players to get at least a general idea of what a card does with only a glance. This formatting can be transcribed to JavaScript's classes, allowing us to describe the structure of a card, and demonstrate how each card can be read and interpreted. Following is what a top level "Card" class might look like. (For the sake of simplicity, we will ignore cards which cannot be included in a deck)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Card Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subTypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;manaCost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rulesText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loreText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keyWords&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;abilities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the basic structure which all Magic: The Gathering cards will follow. Not every one of those fields will be filled on every card, but those are all the attributes which are common to all types of cards. Each type can be understood as a subclass of the "Card" class. For example, we can transcribe one of the simplest card types in the game; the Land Type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Land&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subTypes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Land&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subTypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subTypes&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;abilities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&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%2Fuz2wcjebutyp37gvrw8d.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%2Fuz2wcjebutyp37gvrw8d.png" alt="An image of a Plains Basic Land Card" width="488" height="680"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The systems of Magic apply many more rules, abilities, and conditions to each card, but this Land class allows us to create a simple Land Card. If we wanted to recreate the Plains Basic Land, we would call our Land Class as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Plains&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Land&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Plains&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// card name&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Basic&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Plains&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// types&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;White&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// color identity&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tap: Add 1 White mana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// ability&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="cm"&gt;/* 
  The resulting Card should look something like this:

  {
    name: "Plains",
    type: "Land",
    subTypes: [ "Basic", "Plains" ],
    colors: [ "White" ],
    rulesText = "",
    loreText = "",
    keyWords = [],
    abilities = [ "Tap: Add 1 White mana" ],
  }

*/&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This newly constructed card provides us with some essential information about how it interacts with the game. This information is usually put in the same position on every card. Basic Lands are actually one of the rare examples of a card where it is common for the abilities to not be explicitly printed on the card. This is because of a rule Wizards of the Coast added that tied the ability to tap for mana to the "Basic" typing. So let's try a non-basic Land; Tranquil Expanse.&lt;/p&gt;

&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%2Fxrrkzw6nyasbmcec1wd1.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%2Fxrrkzw6nyasbmcec1wd1.png" alt="An image of a Tranquil Expanse Card" width="672" height="936"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On this card, we can identify several attributes which neatly fit within our class. We have the name ("Tranquil Expanse"), the type ("Land"), some rules text ("This land enters the battlefield tapped"), an ability ("Tap: Add 1 Green or White mana"), and some lore text ("Despite the chaos ..."). Notably this card is lacking subtypes, which is common for non-basic Lands.&lt;/p&gt;

&lt;p&gt;Another type of card is the Creature card. Creatures are among the most iconic and versatile card types in Magic: The Gathering. They represent characters, monsters, and entities that enter the battlefield and can attack your opponents or defend against their creatures. Just like Lands, Creature cards follow a predictable structure that we can extend from our base Card class.&lt;/p&gt;

&lt;p&gt;Let’s define what a Creature subclass might look like in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Creature&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;manaCost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subTypes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;power&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toughness&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rulesText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;keyWords&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loreText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Creature&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subTypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subTypes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;manaCost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;manaCost&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;power&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;power&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toughness&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;toughness&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rulesText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rulesText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keyWords&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;keyWords&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;abilities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loreText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;loreText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This class can be used to describe most creatures in the game. We can use the card Savannah Lions for example;&lt;/p&gt;

&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%2Fkgher2rq3h4e7qy0mvre.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%2Fkgher2rq3h4e7qy0mvre.png" alt="Savannah Lions" width="672" height="936"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SavannahLions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Creature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Savannah Lions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;W&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// W = 1 white mana&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;White&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// power&lt;/span&gt;
  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// toughness&lt;/span&gt;
  &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// no special rules&lt;/span&gt;
  &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="c1"&gt;// no keywords&lt;/span&gt;
  &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="c1"&gt;// no abilities&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Once they ruled the savannah. Now they scrabble for territory at the fringes of civilization.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;In Magic, even a simple creature like Savannah Lions follows the same consistent card structure. This makes it easier for players to understand new cards. As a rule of thumb, creatures always have power and toughness, and often have keywords like "Flying", "Trample", or "First Strike"—shortcuts for specific abilities defined by the rules of the game.&lt;/p&gt;

&lt;p&gt;If you want to learn more about the anatomy of Magic cards, &lt;a href="https://magic.wizards.com/en/news/feature/anatomy-magic-card-2006-10-21" rel="noopener noreferrer"&gt;this is a great source from Wizards itself.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building a Bot With Discord.js</title>
      <dc:creator>joespaf</dc:creator>
      <pubDate>Tue, 30 Sep 2025 14:02:34 +0000</pubDate>
      <link>https://forem.com/joespaf/building-a-bot-with-discordjs-543f</link>
      <guid>https://forem.com/joespaf/building-a-bot-with-discordjs-543f</guid>
      <description>&lt;h2&gt;
  
  
  A quick guide on how to build and launch a Discord bot with Discord.js
&lt;/h2&gt;

&lt;p&gt;By the end of this guide, you will have a Discord bot which will be able to respond to text commands, as well as an idea of how to implement more complicated and interesting features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Prerequisites&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A machine with Node.js installed&lt;/li&gt;
&lt;li&gt;Some familiarity with JavaScript and Node.js&lt;/li&gt;
&lt;li&gt;A Discord account with 2FA enabled&lt;/li&gt;
&lt;li&gt;A Discord server in which you have admin privileges&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Create your application in the Developer Portal&lt;/li&gt;
&lt;li&gt;Go to &lt;a href="https://discord.com/developers/applications" rel="noopener noreferrer"&gt;https://discord.com/developers/applications&lt;/a&gt; and log in.&lt;/li&gt;
&lt;li&gt;Click New Application, give it a name, and hit Create.&lt;/li&gt;
&lt;li&gt;In the sidebar, select Bot and then Add Bot.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under TOKEN, click Copy—you’ll need this in a sec.&lt;br&gt;
Keep your token secret. Never commit it to a public repo!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set up your project files&lt;br&gt;
In your discord-bot directory, create the following files:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;config.json&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;index.js&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a config.json with your bot token and a command prefix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "token": "YOUR_BOT_TOKEN_HERE",
  "prefix": "!"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install and import Discord.js
Run:
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;p&gt;Then, in index.js, bring in Discord.js and your config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { Client, Intents } = require('discord.js');
const { token, prefix } = require('./config.json');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Initialize your client
In index.js, set up a client that listens for messages:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const client = new Client({
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]
});

client.once('ready', () =&amp;gt; {
  console.log(`Logged in as ${client.user.tag}`);
});

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

&lt;/div&gt;



&lt;p&gt;This logs a confirmation when your bot comes online.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handle text commands
Add a messageCreate listener to parse and respond to commands:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.on('messageCreate', message =&amp;gt; {
  if (!message.content.startsWith(prefix) || message.author.bot) return;

  const args = message.content
    .slice(prefix.length)
    .trim()
    .split(/ +/);
  const command = args.shift().toLowerCase();

  if (command === 'ping') {
    message.channel.send('Pong!');
  } else if (command === 'say') {
    const text = args.join(' ');
    if (!text) return message.reply('You need to tell me what to say!');
    message.channel.send(text);
  }
});

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Log in and run your bot
At the bottom of index.js, add:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.login(token);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in your terminal start your bot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;Logged in as YourBotName&lt;/code&gt; in your terminal.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Invite your bot to your server&lt;/li&gt;
&lt;li&gt;Back in the Developer Portal, go to OAuth2 → URL Generator.&lt;/li&gt;
&lt;li&gt;Under SCOPES (the first section), check bot.&lt;/li&gt;
&lt;li&gt;Under BOT PERMISSIONS (the second), select the permissions your bot needs. For the above code, we should only need the "Send Messages" permission.&lt;/li&gt;
&lt;li&gt;Copy the generated URL, open it in your browser, and choose your server.
Your bot will appear in your server’s member list. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You've now created a Discord bot!&lt;/p&gt;

</description>
      <category>discord</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React Native for Web Developers</title>
      <dc:creator>joespaf</dc:creator>
      <pubDate>Mon, 08 Sep 2025 13:41:17 +0000</pubDate>
      <link>https://forem.com/joespaf/react-native-for-web-developers-1464</link>
      <guid>https://forem.com/joespaf/react-native-for-web-developers-1464</guid>
      <description>&lt;p&gt;One of the libraries that new web developers quickly become familiar with is React. Its integration of HTML and JavaScript into one document can supercharge development, allowing developers to quickly and clearly block out and implement features to webpages. However, as mobile usage continues to eclipse desktop, the need for native mobile apps has become paramount. Luckily for web developers, a simple bridge between web and native development exists in React Native.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is React Native?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;"React Native brings the best parts of developing with React to native development." -&lt;em&gt;React Native Docs&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;React Native is a library that translates the straightforward syntax of React into a native app, allowing your projects to be run seamlessly within a user's device. It avoids the hiccups of running a browser by cutting it out entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  No browser? How does the app render?
&lt;/h2&gt;

&lt;p&gt;Instead of a browser, React Native uses the native API's of the device it is running on to display the app. This does require a number of changes from your typical React code, but much of the basic logic and structure remains the same. The most notable difference is the lack of a traditional DOM.&lt;/p&gt;

&lt;h2&gt;
  
  
  What replaces the DOM?
&lt;/h2&gt;

&lt;p&gt;In a web app, the browser creates a DOM to represent the whole of the page, all its elements, and all attributes of those elements. In React, the DOM is populated with components, represented by HTML tags. React Native keeps the style and structure of these tags, but switches the HTML out for its own components.&lt;/p&gt;

&lt;p&gt;HTML tags and their React Native counterparts;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span&amp;gt; =&amp;gt; &amp;lt;Text&amp;gt;
&amp;lt;img&amp;gt; =&amp;gt; &amp;lt;Image&amp;gt;
&amp;lt;div&amp;gt; =&amp;gt; &amp;lt;View&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Styling without CSS
&lt;/h2&gt;

&lt;p&gt;React Native does not have a built in way to use CSS. Instead, styling is provided to components as a JavaScript object. It can be provided inline, with the declaration of the component, or the &lt;code&gt;StyleSheet&lt;/code&gt; module can be used to provide styles to components.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// inline
&amp;lt;View style={{ padding : 15 }} /&amp;gt;

// using StyleSheet
import { StyleSheet } from 'react-native'

const styles = StyleSheet.create({
  container: {
    padding: 15
    backgroundColor: '#fff'
  }
});

&amp;lt;View style={styles.container} /&amp;gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Navigation without a browser
&lt;/h2&gt;

&lt;p&gt;One of the most significant differences between React and React Native is navigation. In a React web app, navigation is often handled with changes to the URL, which libraries like &lt;code&gt;react-router&lt;/code&gt; take full advantage of. A native app handles displays in a fundamentally different way. Both iOS and Android phones display Screens, and they handle navigation between Screens as a stack, where a new Screen enters on top of the previous one. From a Screen, a user can go back down the stack to previous Screens. &lt;/p&gt;

&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%2Fw50ud3brtpjeiscg367l.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%2Fw50ud3brtpjeiscg367l.png" alt="A simple graphic of a phone with layered panels labeled " width="458" height="734"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where does the JavaScript go?
&lt;/h2&gt;

&lt;p&gt;JavaScript in React Native behaves much the same as it does in a browser environment, just with a few exceptions. Most notably, it loses access to values and APIs that the browser would provide, like &lt;code&gt;document&lt;/code&gt;, &lt;code&gt;window&lt;/code&gt;, and workers. Other than that, JavaScript can be used similarly to how it is used in any other React app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Community support
&lt;/h2&gt;

&lt;p&gt;React famously has countless officially supported and community maintained libraries that expand its capabilities. Similarly, React Native has a plethora of options for almost any use case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;React Native is a familiar yet powerful tool that web developers can use to apply their existing skills to app development. Its widespread usage, unopinionated framework, and community support make it invaluable for any developer looking to dip their feet into native apps.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>reactnative</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Tapping into Mobile Design</title>
      <dc:creator>joespaf</dc:creator>
      <pubDate>Mon, 02 Jun 2025 13:58:24 +0000</pubDate>
      <link>https://forem.com/joespaf/tapping-into-mobile-design-39on</link>
      <guid>https://forem.com/joespaf/tapping-into-mobile-design-39on</guid>
      <description>&lt;p&gt;&lt;em&gt;A quick guide on making a site mobile friendly&lt;/em&gt;&lt;/p&gt;

&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%2Fp5b2bygdxjmgp2yylwot.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%2Fp5b2bygdxjmgp2yylwot.png" alt=" " width="526" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Over the past decade, mobile users have begun to represent more and more of the global web traffic. Mobile traffic has doubled its share, climbing from around 30% in 2015 to over 60% in 2024. With such a large share of users, it is important for developers to design their sites with special attention on compatibility and ease of use on mobile devices. &lt;/p&gt;

&lt;h2&gt;
  
  
  Think Vertically
&lt;/h2&gt;

&lt;p&gt;Unlike desktop screens, mobile displays are narrow and vertically oriented, meaning horizontal layouts with multiple columns can become a highly unpleasant experience. A single-column design is ideal, ensuring that text, images, and other elements stack neatly without forcing users to scroll sideways or zoom in. If necessary, more columns can be included, but really shouldn't go above 2, as it can be verry difficult to include all of them without destroying the legibility of their contents.&lt;br&gt;
A vertical approach also improves scannability, helping users find information quickly. Lists, short paragraphs, and distinct sections keep content concise and digestible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Larger Font Sizes
&lt;/h2&gt;

&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%2Fnmtzotiivnz6pbs5fyvb.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%2Fnmtzotiivnz6pbs5fyvb.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Small text can be difficult to read on mobile screens, so increasing the font size does a lot to improve usability. As a general rule, body text should be at least 16px, with headlines and important information even larger.&lt;br&gt;
Headers are equally crucial: they provide visual hierarchy, guiding users through sections effortlessly. By using clear, bold headers, you break up dense information into structured, easy-to-read sections. This is particularly helpful for users scanning rather than reading every word.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimize Touch Interactions with Pointer Events
&lt;/h2&gt;

&lt;p&gt;Mobile users rely on touchscreens, making traditional mouse-based interactions (such as hover effects) ineffective. Instead of designing around hover states or precise mouse clicks, use pointer events, which are more adaptable.&lt;br&gt;
Pointer events recognize touch, stylus, and mouse inputs, making interactions smoother for all users—including those using assistive technologies. This ensures buttons, links, and interactive elements respond instantly without needing a cursor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ensure Visually Responsive Elements
&lt;/h2&gt;

&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%2F2hl6o5kwlsqfnk1s1a6p.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%2F2hl6o5kwlsqfnk1s1a6p.png" alt=" " width="339" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A mobile-friendly site must adapt dynamically to different screen sizes, resolutions, and orientations. This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using fluid grid layouts that resize automatically.&lt;/li&gt;
&lt;li&gt;Ensuring images are scalable and do not distort.&lt;/li&gt;
&lt;li&gt;Testing buttons and forms to guarantee they remain usable on smaller screens.
CSS media queries allow developers to define specific rules for different screen sizes. Testing responsiveness across various devices prevents common issues, such as cut-off images, unreadable text, or misplaced buttons.
Implementing sliding animations can also improve how responsive a site feels. A menu or other sidebar item that slides in correspondence with the user's swipe will help them to understand where the element is coming from, as well as how to access it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;A site that isn’t optimized for mobile risks losing engagement and frustrating a large portion of users. By prioritizing vertical layouts, legible fonts, touch-based interactions, and responsive design, developers create a seamless experience tailored to modern browsing habits.&lt;br&gt;
Think of mobile optimization as essential, not optional—your users will thank you for it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Basic Git Commands</title>
      <dc:creator>joespaf</dc:creator>
      <pubDate>Wed, 20 Nov 2024 23:46:28 +0000</pubDate>
      <link>https://forem.com/joespaf/basic-git-commands-230b</link>
      <guid>https://forem.com/joespaf/basic-git-commands-230b</guid>
      <description>&lt;p&gt;Git repositories are files that track changes made to projects, allowing users to access alternative versions of their code. This has many useful applications, including collaborative coding, debugging, and drafting code before a final product. To be able to make use of these features, you must know what commands to call and in what order to do so.&lt;/p&gt;

&lt;p&gt;Before you can make use of any git features, you need to give it a name for you as a user and an email to associate with your user.&lt;br&gt;
Use the following commands to do so:&lt;br&gt;
&lt;code&gt;git config --global user.name "(insert name here)"&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git config --global user.email "(insert email here)"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you can create a repository. Navigate to the directory containing your project and enter this command:&lt;br&gt;
&lt;code&gt;git init&lt;/code&gt;&lt;br&gt;
This will create your repository, but it does not automatically fill it with the contents of the directory. To do so, you will need to stage them with the add command, which looks like this:&lt;br&gt;
&lt;code&gt;git add (file)&lt;/code&gt;&lt;br&gt;
Or, if you want to add all files in the current directory:&lt;br&gt;
&lt;code&gt;git add --all&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you decide you don't actually want to add a file, or mistakenly added one you don't want tracked, you can use the restore command to remove it from staging. This command can also be used to restore a file to how it was in a previous commit.&lt;br&gt;
&lt;code&gt;git restore (file)&lt;/code&gt;&lt;br&gt;
It can also be called with &lt;code&gt;--staged&lt;/code&gt; in the place of &lt;code&gt;(file)&lt;/code&gt; to remove all staged changes&lt;/p&gt;

&lt;p&gt;Now these files are staged to be committed to the repository. You can see a list of all the files that the repository is tracking with the status command:&lt;br&gt;
&lt;code&gt;git status&lt;/code&gt;&lt;br&gt;
This will also show the status of those files; whether or not they have changed since the last time they were committed.&lt;br&gt;
That brings us to the commit command. This command will save the staged changes to the repository. Notably this does not overwrite any previous commits, so you can and should commit frequently. The command also takes a message to label the commit with, which should be used to describe the changes made since the last commit.&lt;br&gt;
The commit command looks like:&lt;br&gt;
&lt;code&gt;git commit -m "(description)"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After there is at least one commit in the repository, you can use the log command to see a list of all commits, along with their messages, authors, and when they were committed. &lt;br&gt;
&lt;code&gt;git log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The log command also provides a hash associated to each commit, allowing you to navigate to older commits with the checkout command. You could use the entire hash, but only the first seven characters are necessary.&lt;br&gt;
&lt;code&gt;git checkout (hash)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Another useful feature is branching. Branching allows you to work without affecting the main codebase. This can be useful for chasing down specific bugs or problems without messing with the main branch.&lt;br&gt;
To create a branch, use the following code:&lt;br&gt;
&lt;code&gt;git branch (branch name)&lt;/code&gt;&lt;br&gt;
Once you've made a branch, you can navigate to it with the checkout command&lt;br&gt;
&lt;code&gt;git checkout (branch name)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After a branch's purpose has been fulfilled, it should be merged back into the main branch. Doing so will usually create conflicts, which you will need to go through your code and resolve.&lt;br&gt;
Before you merge a branch, you need to navigate to the branch it originally split from. In this case it will be the main branch.&lt;br&gt;
&lt;code&gt;git checkout main&lt;/code&gt;&lt;br&gt;
Next, you need to use the merge command with the branch name.&lt;br&gt;
&lt;code&gt;git merge (branch name)&lt;/code&gt;&lt;br&gt;
After resolving all conflicts in a merge, you can stage and commit the files.&lt;br&gt;
&lt;code&gt;git add .&lt;/code&gt;&lt;br&gt;
`git commit -m "merged (branch name) to main"&lt;/p&gt;

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