<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Carl J</title>
    <description>The latest articles on DEV Community by Carl J (@ccjavier87).</description>
    <link>https://dev.to/ccjavier87</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%2F1019287%2F84057702-ee4e-4e61-8b5b-34fbc5a19b3d.jpeg</url>
      <title>DEV Community: Carl J</title>
      <link>https://dev.to/ccjavier87</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ccjavier87"/>
    <language>en</language>
    <item>
      <title>Phase 1 Project</title>
      <dc:creator>Carl J</dc:creator>
      <pubDate>Tue, 28 Mar 2023 01:39:38 +0000</pubDate>
      <link>https://dev.to/ccjavier87/phase-1-project-2635</link>
      <guid>https://dev.to/ccjavier87/phase-1-project-2635</guid>
      <description>&lt;p&gt;Here's my post about my html app.&lt;br&gt;
My original idea was to do something related to medical diseases where the app would output a list of possible diseases, given a set of symptoms. I was hoping to possibly mimic WebMD or Mayo Clinic websites.&lt;br&gt;
The API available to me was Lexigram Clinical NLP APIs (&lt;a href="https://docs.lexigram.io/"&gt;https://docs.lexigram.io/&lt;/a&gt;). Instructions to use it felt overwhelming to me and it required an API key, so I looked for another topic.&lt;br&gt;
Anyway, I went with Dad Jokes. It can't get any simpler than this, right?&lt;br&gt;
The api page: &lt;a href="https://icanhazdadjoke.com/"&gt;Dad Joke Link&lt;/a&gt;. I'll come back to this.&lt;/p&gt;
&lt;h3&gt;
  
  
  Project Start
&lt;/h3&gt;

&lt;p&gt;So the project... let's look at the &lt;code&gt;README.md&lt;/code&gt;&lt;br&gt;
Some goals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Design and architect features across a frontend (I'm guessing the look and feel, and style of the html page)&lt;/li&gt;
&lt;li&gt;Communicate and collaborate in a technical environment (??)&lt;/li&gt;
&lt;li&gt;Integrate JavaScript and an external API (k got it)&lt;/li&gt;
&lt;li&gt;Debug issues in small- to medium-sized projects (sure)&lt;/li&gt;
&lt;li&gt;Build and iterate on a project MVP &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Actually starting the project
&lt;/h3&gt;

&lt;p&gt;Like many beginners in coding, I did not know where to start. Thankfully I can use pseudo code to describe what it is I want the app to do.&lt;br&gt;
Essentially, I wanted the app to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have a picture background related to the joke displayed&lt;/li&gt;
&lt;li&gt;Get a random joke. Preferably when page loads.&lt;/li&gt;
&lt;li&gt;Have a random button that produces a random joke.&lt;/li&gt;
&lt;li&gt;Have users search for a joke, which means the background should also change to the searched term.&lt;/li&gt;
&lt;li&gt;Have a search button exist.&lt;/li&gt;
&lt;li&gt;Search button does something when mouse is hovering over the buttons.&lt;/li&gt;
&lt;li&gt;Fetch a random joke if the search bar is empty.&lt;/li&gt;
&lt;li&gt;Save the joke onto a list of favorite jokes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;.html, .css, and .js documents were made.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch `index.html`, touch `style.css`, and `script.js`
### HTML
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I type &lt;code&gt;!&lt;/code&gt; in he html document, I get a drop-down list containing pre-written set of html code:&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;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Designing the HTML and CSS, in a way is like creating an outline of what the app would do.&lt;br&gt;
I know for sure that I would be using /.script.js for functions and /.style.css for page design. I did this by putting in links as below:&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;!--STYLE--&amp;gt;
    &amp;lt;link rel="stylesheet" href="./style.css"&amp;gt;
&amp;lt;!--END OF STYLE--&amp;gt;

&amp;lt;!--JS SCRIPT--&amp;gt;
    &amp;lt;script src="./script.js" defer&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;!--END OF JS SCRIPT--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example I want the fonts in the app to include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gloria Hallelujah&lt;/li&gt;
&lt;li&gt;Open Sans&lt;/li&gt;
&lt;li&gt;Permanent Marker
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="preconnect" href="https://fonts.googleapis.com"&amp;gt;
&amp;lt;link rel="preconnect" href="https://fonts.gstatic.com" crossorigin&amp;gt;
&amp;lt;link href="https://fonts.googleapis.com/css2?family=Gloria+Hallelujah&amp;amp;family=Open+Sans&amp;amp;family=Permanent+Marker&amp;amp;display=swap" rel="stylesheet"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Time for the Inputs (all inside the body)
&lt;/h4&gt;

&lt;p&gt;Within the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; that was created, I had to insert a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; within the card. And then I should be able to type some search item in the search box. Looks like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body style="overflow:scroll"&amp;gt;
    &amp;lt;div class="card"&amp;gt;
        &amp;lt;div class="search"&amp;gt;
            &amp;lt;input type="text" class="searchBar"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But I need a button...&lt;br&gt;
For this button, I decided to insert a photo search icon on it, so I used React Icons by opening up a Command Palette.&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;button id="randomButton"&amp;gt;
   &amp;lt;svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 496 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"&amp;gt;
      &amp;lt;path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm33.8 161.7l80-48c11.6-6.9 24 7.7 15.4 18L343.6 180l33.6 40.3c8.7 10.4-3.9 24.8-15.4 18l-80-48c-7.7-4.7-7.7-15.9 0-20.6zm-163-30c-8.6-10.3 3.8-24.9 15.4-18l80 48c7.8 4.7 7.8 15.9 0 20.6l-80 48c-11.5 6.8-24-7.6-15.4-18l33.6-40.3-33.6-40.3zM398.9 306C390 377 329.4 432 256 432h-16c-73.4 0-134-55-142.9-126-1.2-9.5 6.3-18 15.9-18h270c9.6 0 17.1 8.4 15.9 18z"&amp;gt;
      &amp;lt;/path&amp;gt;
    &amp;lt;/svg&amp;gt;
 &amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next is the space/div for where the code will be displayed.&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;div class="jokes"&amp;gt;
   &amp;lt;h2 class="theJoke"&amp;gt;Here comes the Joke...&amp;lt;/h2&amp;gt;
   &amp;lt;div class="jokeList" &amp;gt;
      &amp;lt;h4&amp;gt;All Jokes with searched topic&amp;lt;/h4&amp;gt;
   &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Style Sheet
&lt;/h2&gt;

&lt;p&gt;General Header and body styling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html {
  /* Background image? */
  background: url(https://source.unsplash.com/random/?father+child) no-repeat center center fixed;
  background-size: cover;
  /* End background image */
  height: 100%;
  overflow: hidden;
}
/* specify design of body of page */
body {
  display: flex;
  justify-content: center;
  height: 100vh;
  margin: 0;
  align-items: center;
  align-content: center;
  /* Fonts here */
  font-family: 'Open Sans', sans-serif;
  font-family: 'Permanent Marker', cursive;
  font-family: 'Gloria Hallelujah', cursive;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The header is where I declared a random image to be used when the page loads.&lt;/p&gt;

&lt;p&gt;The rest of the .css design was basic and I used the Chrome inspector to see changes in the html in real time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Javascript
&lt;/h2&gt;

&lt;p&gt;This was probably the hardest part of the project for me.&lt;br&gt;
We start with the main function of joke &lt;code&gt;function getJoke () {}&lt;/code&gt; and in this function we have our &lt;code&gt;fetch&lt;/code&gt; and &lt;code&gt;.then&lt;/code&gt;s. &lt;br&gt;
The fetch uses the url, "&lt;a href="https://icanhazdadjoke.com/"&gt;https://icanhazdadjoke.com/&lt;/a&gt;" from the Dad Jokes API. This url apparently outputs a random Dad Joke. But let's test it! To see what kind/type/nature of data I get, I used &lt;code&gt;console.log&lt;/code&gt; of the data output. The &lt;code&gt;.then&lt;/code&gt;s were using arrow functions at this time. This is the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getJoke () {
   fetch ("https://icanhazdadjoke.com/")
   .then ( (response) =&amp;gt; response.json() )
   .then ( (data) =&amp;gt; console.log(data))
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SyntaxError: Unexpected token &amp;lt; in JSON at position 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we got an error!&lt;br&gt;
What I realized was that I needed to add a header. As mentioned in the Dad Joke API instructions, I needed a header in the &lt;code&gt;fetch&lt;/code&gt; to &lt;code&gt;Accept: application/json&lt;/code&gt;. So I tried again...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getJoke () {
   fetch ("https://icanhazdadjoke.com/", {
            headers: {
                'Accept': 'application/json'
            }
        })
   .then ( (response) =&amp;gt; response.json() )
   .then ( (data) =&amp;gt; console.log(data))
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which produced an output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  id: 'lV8hqHexHBd',
  joke: 'Why did the worker get fired from the orange juice factory? Lack of concentration.',
  status: 200
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok great! I used this for a function: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;triggered by a button labeled "Random"&lt;/li&gt;
&lt;li&gt;produces a random Dad joke&lt;/li&gt;
&lt;li&gt;that is called on when a search value is blank
Like so:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getRandom: function () {
        fetch("https://icanhazdadjoke.com/",
        {
            headers: {
                'Accept': 'application/json'
            }
        })
            .then((response) =&amp;gt; response.json())
            .then((randJoke) =&amp;gt; this.displayJoke(randJoke))
            .catch((error) =&amp;gt; console.log("error"))
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;displayJoke&lt;/code&gt; function would print out the joke in the section with the class name &lt;code&gt;theJoke&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;displayJoke: function (data) {
        const joke = data.joke;
        document.querySelector(".theJoke").innerText = joke;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, what if I wanted a joke that included values I typed in the search box? &lt;br&gt;
The Dad joke API source had instruction to use the link, &lt;code&gt;"https://icanhazdadjoke.com/search?term="&lt;/code&gt;, in order to produce jokes with the search item. The default for "term" would list all the jokes available. Therefore, the variable "searchTerm" would be used as the input typed in the search box.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let joke = {
    getJoke: function (searchTerm) {
        fetch("https://icanhazdadjoke.com/search?term=" + searchTerm + ""
        , {
            headers: {
                'Accept': 'application/json'
            }
        })
            .then((response) =&amp;gt; response.json())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;"https://icanhazdadjoke.com/search?term="&lt;/code&gt; AP, however, produced a list of jokes with the search term. So in order to display a joke, I wanted to randomize jokes in the list. I did this as a function in a &lt;code&gt;.then&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getJoke: function (searchTerm) {
        fetch("https://icanhazdadjoke.com/search?term=" + searchTerm + ""
        , {
            headers: {
                'Accept': 'application/json'
            }
        })
            .then((response) =&amp;gt; response.json())
            .then((data) =&amp;gt; {
                let randNum = Math.floor(Math.random() * data.results.length);
                return this.displayJoke(data.results[randNum])
            })
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when I created the function &lt;code&gt;searchJoke&lt;/code&gt;, it would use call the function &lt;code&gt;getJoke&lt;/code&gt; and produce a random joke from the list of searched jokes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;searchJoke: function () {
        this.getJoke(document.querySelector(".searchBar").value);
        document.querySelector(".searchBar").value = "";
    },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I decided to put all these functions in an object so that I can call on these functions in dot format (i.e. joke.getJoke).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let joke = {
    getJoke: function (searchTerm) {
        fetch("https://icanhazdadjoke.com/search?term=" + searchTerm + ""
        , {
            headers: {
                'Accept': 'application/json'
            }
        })
            .then((response) =&amp;gt; response.json())
            .then((data) =&amp;gt; {
                let randNum = Math.floor(Math.random() * data.results.length);
                return this.displayJoke(data.results[randNum])

            })
    },

//get a random joke (prefer when loading page)
    getRandom: function () {
        fetch("https://icanhazdadjoke.com/",
        {
            headers: {
                'Accept': 'application/json'
            }
        })
            .then((response) =&amp;gt; response.json())
            .then((randJoke) =&amp;gt; this.displayJoke(randJoke))
            .catch((error) =&amp;gt; console.log("error"))
    },
//search for a joke
    searchJoke: function () {

        this.getJoke(document.querySelector(".searchBar").value);
        document.querySelector(".searchBar").value = "";
    },

//display the joke searched
    displayJoke: function (data) {
        const joke = data.joke;
        document.querySelector(".theJoke").innerText = joke;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add Event Listeners
&lt;/h2&gt;

&lt;p&gt;Great! so next to do was create &lt;code&gt;addEventListener&lt;/code&gt;s.&lt;br&gt;
Created a random button and when clicked should execute &lt;code&gt;getRandom&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var randButt = document.querySelector("#randomButton")
randButt.addEventListener("click", function () {
    joke.getRandom();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;addEventListener for search button&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var searchButt = document.querySelector(".searchButton");

//search for a joke when search button clicked or tap or selected
searchButt.addEventListener("click", function() {
    joke.searchJoke();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mouse-over &amp;amp; Mouse-out
&lt;/h3&gt;

&lt;p&gt;When mouse cursor is over the random button, it would display the text "Random Dad Joke" and when mouse out, shows an emoji icon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;randButt.addEventListener("mouseover", function () {
    randButt.innerText = 'Random Dad Joke';
});

randButt.addEventListener("mouseout", function () {
    randButt.innerHTML = '&amp;lt;svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 496 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm33.8 161.7l80-48c11.6-6.9 24 7.7 15.4 18L343.6 180l33.6 40.3c8.7 10.4-3.9 24.8-15.4 18l-80-48c-7.7-4.7-7.7-15.9 0-20.6zm-163-30c-8.6-10.3 3.8-24.9 15.4-18l80 48c7.8 4.7 7.8 15.9 0 20.6l-80 48c-11.5 6.8-24-7.6-15.4-18l33.6-40.3-33.6-40.3zM398.9 306C390 377 329.4 432 256 432h-16c-73.4 0-134-55-142.9-126-1.2-9.5 6.3-18 15.9-18h270c9.6 0 17.1 8.4 15.9 18z"&amp;gt;&amp;lt;/path&amp;gt;&amp;lt;/svg&amp;gt;';
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same goes for the search button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//change search button to solid when mouse over
searchButt.addEventListener("mouseover", function () {
    searchButt.setAttribute("style", "background-color:white;")
}, false);
//change search button back to original when mouse out
searchButt.addEventListener("mouseout", function () {
    searchButt.setAttribute("style", "background-color:#7c7c7c2b;")
}, false);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I wanted to edit a couple things for the search box. When pressing "enter" or "return" an input, I want the search button to activate. But when the input box is empty, I want it to run the random joke function &lt;code&gt;joke.getRandom()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//search for joke when press Enter key
document.querySelector(".searchBar").addEventListener("keyup", function (e) {
    if (e.key === "Enter") {
        e.preventDefault()
        document.querySelector(".searchButton").click();
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then added this to the search button event listener&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//run random joke if search bar is empty
    if (document.querySelector(".searchBar").value === null || "") 
    {
       joke.getRandom();
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>html</category>
      <category>javascript</category>
      <category>css</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JS Variables</title>
      <dc:creator>Carl J</dc:creator>
      <pubDate>Fri, 24 Mar 2023 19:21:53 +0000</pubDate>
      <link>https://dev.to/ccjavier87/js-variables-4a2k</link>
      <guid>https://dev.to/ccjavier87/js-variables-4a2k</guid>
      <description>&lt;p&gt;To start with JS, or any coding platform, we must declare variables... or assign a value to it.&lt;br&gt;
Say you are talking to someone about a subject and spit out a word that has never been heard before. The person you're talking to would not know what that word is, so he/she/they would ask you, "What is this 'word' you speak of?"&lt;br&gt;
So, we have to define this word. It can either be an object, a description, an expression... and so on.&lt;br&gt;
So with JS we can use 'const', 'let', or 'var' to declare that a variable (i.e. "x", "y", "zed", or whatever) is something, well "valuable". Take "x" for example; we know what it is, but the computer surely doesn't know. So let's declare this variable as something important.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const x;
//or
let x;
//or
var x;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can even give it a value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const x = 42;
let y = 6*7;
let zed = "pizza pizza";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, that's it for now.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>1st Dev post</title>
      <dc:creator>Carl J</dc:creator>
      <pubDate>Fri, 24 Mar 2023 18:39:56 +0000</pubDate>
      <link>https://dev.to/ccjavier87/1st-dev-post-1gb3</link>
      <guid>https://dev.to/ccjavier87/1st-dev-post-1gb3</guid>
      <description>&lt;p&gt;Here goes my first blog post related to coding.&lt;/p&gt;

&lt;p&gt;Well... my first time coding was with C+, which was a long time ago.&lt;br&gt;
The first thing I did with C+ was to write lines of code that would output the words "Hello World" onto a console screen. As seen below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

int main() {
    std::cout &amp;lt;&amp;lt; "Hello World!";
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I guess that's how everyone starts out. Even with JavaScript (JS).&lt;br&gt;
But with JS it's written:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Hello World');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...so much simpler. This is one of the reasons I like to learn JS.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>hello</category>
    </item>
  </channel>
</rss>
