<?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: Stephanie Sison</title>
    <description>The latest articles on DEV Community by Stephanie Sison (@stejosi).</description>
    <link>https://dev.to/stejosi</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%2F863533%2Fe919435f-e960-427f-8f02-d5a4e0174583.jpeg</url>
      <title>DEV Community: Stephanie Sison</title>
      <link>https://dev.to/stejosi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stejosi"/>
    <language>en</language>
    <item>
      <title>CRUD Routing with Sinatra</title>
      <dc:creator>Stephanie Sison</dc:creator>
      <pubDate>Sat, 11 Feb 2023 04:50:36 +0000</pubDate>
      <link>https://dev.to/stejosi/crud-routing-with-sinatra-h06</link>
      <guid>https://dev.to/stejosi/crud-routing-with-sinatra-h06</guid>
      <description>&lt;p&gt;I am currently finishing up my project for the third phase in my Software Engineer bootcamp. In this phase, I learned how to use Ruby.&lt;/p&gt;

&lt;p&gt;For this project, students were to design a web app of their choice. Using React for the front-end and Ruby for the back-end. My project is a web application where a user can create a post of their choice. The client can view all the posts or only posts associated with a specific user. The client can also create a profile so they are able to make posts as well.&lt;/p&gt;

&lt;p&gt;In a standard Ruby application, you would have migrations, models, and controllers. &lt;br&gt;
&lt;strong&gt;Migrations&lt;/strong&gt; allow you to modify your database in a efficient way. You can create a table, drop the table, add more information to the table and so on. &lt;br&gt;
&lt;strong&gt;Models&lt;/strong&gt; inherit &lt;strong&gt;Active Record::Base&lt;/strong&gt; which holds all the methods that allow you to interact with your database.&lt;br&gt;
Now the &lt;strong&gt;Controllers&lt;/strong&gt; are the main star of your application. It coordinates the interaction between the user, the views, and the model, along with a number of other things.&lt;/p&gt;

&lt;p&gt;So, lets begin creating our application to handle our CRUD actions. &lt;/p&gt;

&lt;p&gt;Let's start with creating a table and migrating it to our database schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateUsers &amp;lt; ActiveRecord::Migration[6.1]
  def change
    create_table :users do |t|
      t.string :first_name
      t.string :last_name
      t.string :email
      t.string :username
      t.string :password
      t.timestamps
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will now have a Models folder that will contain a user file with a User class. As you can see below, we have a "has_many" macro inside of our User class. This is a one-to-many association. This tells the User class that each user instance can have many posts. We can now access a list of posts that is associated with a user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User &amp;lt; ActiveRecord::Base
    has_many :posts
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And lastly, we have a Controllers folder. Inside of that folder, we have a users_controller file with a UsersController class. That class will hold out CRUD actions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class UsersController &amp;lt; ApplicationController
    // methods will go in here    
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have every thing set up accordingly, we can proceed to coding out our routes. The routes will communicate with the frontend of our application to allow users to &lt;strong&gt;C&lt;/strong&gt;reate, &lt;strong&gt;R&lt;/strong&gt;ead, &lt;strong&gt;U&lt;/strong&gt;pdate, and &lt;strong&gt;D&lt;/strong&gt;elete information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class UsersController &amp;lt; ApplicationController
    get '/users' do

    end

    post '/users' do

    end

    patch '/users/:id' do

    end

    delete '/users/:id' do

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

&lt;/div&gt;



&lt;p&gt;We now have our layout of our routes. Let's run through what each route will do.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;get&lt;/strong&gt; request is the &lt;strong&gt;Read&lt;/strong&gt; portion of our &lt;strong&gt;CRUD&lt;/strong&gt; actions. This route will allow the client to see all of our users in the database. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;post&lt;/strong&gt; request is our &lt;strong&gt;Create&lt;/strong&gt; portion of our &lt;strong&gt;CRUD&lt;/strong&gt; actions. This route will be used to create a new user and add it to our database. We will first have to get all of the data that the user entered into the form. This will be done in the body of our request. Next, we will use that data to create a new user. And finally, we will send a response of the newly created user as a JSON object to add to our database.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;patch&lt;/strong&gt; request is our &lt;strong&gt;Update&lt;/strong&gt; portion of our &lt;strong&gt;CRUD&lt;/strong&gt; actions. This route will be used to update an existing user from our database. We would first want to find the user that we are updating by their ID number. We then will use that data to update our selected users' password. And then send that response as a JSON object to our database. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;delete&lt;/strong&gt; request is obviously our &lt;strong&gt;Delete&lt;/strong&gt; portion of our &lt;strong&gt;CRUD&lt;/strong&gt; application. This route will be used to delete an existing user from our database. We will find the user that we would like to delete by their ID number, delete the user, and send that response as a JSON. Although in this case, we do not necessarily need to send the response as a JSON object as there would be no data to send because we deleted the user. Instead, we can have an error code that states the user object was deleted.&lt;/p&gt;

&lt;p&gt;Now that we know what each request will do for our clients, lets fill in our routes to match their description.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class UsersController &amp;lt; ApplicationController

    get '/users' do
        users = User.order(:username)
        users.to_json(include: :posts)
    end

    post '/users' do
        users = User.create(
            first_name: params[:first_name],
            last_name: params[:last_name],
            email: params[:email],
            username: params[:username],
            password: params[:password]
        )
        users.to_json(include: :posts)
    end

    patch '/users/:id' do
        users = User.find(params[:id])
        users.update(
            password: params[:password]
        )
        users.to_json(include: :posts)
    end

    delete '/users/:id' do
        users = User.find(params[:id])
        users.destroy
        users.to_json
        puts "This user has been deleted"
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in our get, post, and patch requests, the last line of our code is taking that updated information and sending it as a JSON. But in parenthesis next to it, we have &lt;strong&gt;(include: :posts)&lt;/strong&gt;. We are sending the users, plus the posts that were created by that user as well. &lt;/p&gt;

&lt;p&gt;We have now successfully created a &lt;strong&gt;CRUD&lt;/strong&gt; application and with that knowledge, you can create all the applications your heart desires. &lt;/p&gt;

&lt;p&gt;Happy Coding (:&lt;/p&gt;

</description>
      <category>communication</category>
      <category>management</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Let Me Get You Hooked On useState</title>
      <dc:creator>Stephanie Sison</dc:creator>
      <pubDate>Sun, 23 Oct 2022 06:51:26 +0000</pubDate>
      <link>https://dev.to/stejosi/let-me-get-you-hooked-on-usestate-50cf</link>
      <guid>https://dev.to/stejosi/let-me-get-you-hooked-on-usestate-50cf</guid>
      <description>&lt;p&gt;As I wrap up learning about React in Phase 2 of my program, I would like to talk about when to use the useState Hook. It was one that had me quite confused at the start of learning it, but now I think I have a better grasp on it. &lt;/p&gt;

&lt;p&gt;In React, there is a bunch of different hooks that you are able to implement. One in particular is the useState Hook. &lt;/p&gt;

&lt;p&gt;The useState Hook allows us to track state in a function component. It is dynamic in a component, meaning the data it holds changes over time as users interact with the application. The useState Hook allows us to maintain and update information or data within a component without the parent component having to be involved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Importing useState&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In order to use the useState Hook, you have to import a function from React called &lt;code&gt;useState&lt;/code&gt;. By doing so, it allows us to connect to React's internal state inside of our function component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from "react";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Initializing useState&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now the next step would be to initialize the &lt;code&gt;useState&lt;/code&gt; Hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from "react";

function HeartButton() {
  const [click, setClick] = useState(false);

  return &amp;lt;button&amp;gt;{click}&amp;lt;/button&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Setting State&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The example above came from my Phase 2 project. I wanted to implement a button in the shape of a heart. When the page has loaded, the heart button will appear as an outline of a heart and when the heart button is clicked, it will appear as a solid heart. By setting the initial value to false, we are telling React to create some new internal state for our component. In my case, an initial value of false, i.e. a heart outline.&lt;/p&gt;

&lt;p&gt;The first item in the array, &lt;code&gt;click&lt;/code&gt;, is a reference to the current value of that state. The second item in the array is the setter function, in our case, &lt;code&gt;setClick&lt;/code&gt;. It can be called whenever we want to update the state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from "react";

function HeartButton() {
  const [click, setClick] = useState(false)

  function heart() {
     setClick((click) =&amp;gt; !click)
  }

  const emptyHeart = &amp;lt;ion-icon name="heart-outline"&amp;gt;&amp;lt;/ion-icon&amp;gt;
  const filledHeart = &amp;lt;ion-icon name="heart"&amp;gt;&amp;lt;/ion-icon&amp;gt;

  return (
     &amp;lt;button onClick={heartButton}&amp;gt;
        {click ? filledHeart : emptyHeart}
     &amp;lt;/button&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the button is clicked, it will run the &lt;code&gt;heart&lt;/code&gt; function. Inside the &lt;code&gt;heart&lt;/code&gt; function, it will update the value of &lt;code&gt;click&lt;/code&gt; in the internal state to either be "false" or "true" depending on whether we want to like the picture or not like the picture and it will re-render our component. &lt;/p&gt;

&lt;p&gt;In a more elaborate version, when we click the heart button or we call the &lt;code&gt;HeartButton&lt;/code&gt; function, it translate to this: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Calling &lt;code&gt;useState(true)&lt;/code&gt; tells React to change our default 
state for the &lt;code&gt;HeartButton&lt;/code&gt; component's &lt;code&gt;like&lt;/code&gt; value from 
false to true.&lt;/li&gt;
&lt;li&gt;React updates its internal state&lt;/li&gt;
&lt;li&gt;React re-renders the &lt;code&gt;HeartButton&lt;/code&gt; component&lt;/li&gt;
&lt;li&gt;After being re-rendered, the &lt;code&gt;useState&lt;/code&gt; will return the 
current value of React's internal state, which is now true.&lt;/li&gt;
&lt;li&gt;The value of &lt;code&gt;like&lt;/code&gt; is now true with our &lt;code&gt;HeartButton&lt;/code&gt; 
component.&lt;/li&gt;
&lt;li&gt;The component's JSX uses this new value to display a solid 
heart button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The best part about the useState Hook is all the behind the scenes action that we no longer have to take extra steps and do manually. We no longer have to worry about finding the button element and displaying the new value, it is all done internally. React will automatically re-render the component, any child components involved, and update the DOM as long as we implement the &lt;code&gt;HeartButton&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It is Asynchronous!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One important thing about using the useState Hook is that it sets state asynchronously. When calling the &lt;code&gt;HeartButton&lt;/code&gt; function, the component will finish what the current task is before updating the state. It is only a problem when using the useState Hook for values that are calculated based on the current value of state. In the case of my project, it is not a big deal, but before this tricks you, React recommends a different syntax for setting state. Here is an example, if you were to use state for a counter. &lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function increment() {
  setCount(count + 1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function increment() {
  setCount((currentCount) =&amp;gt; currentCount + 1);
  setCount((currentCount) =&amp;gt; currentCount + 1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The callback syntax is recommended if you need to set state based on the current value of state. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Rules&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lastly, it would not be coding without any rules. The ones associated with Hooks are not actually too complicated. You can only call Hooks at the top level. It needs to live right under the start of your function component. It is invalid syntax if you call Hooks inside loops, conditions, or nested functions. The second rule for Hooks is to only call Hooks from React Functions.  They are only allowed to live in React components and are not allowed to move to regular JavaScript function.&lt;/p&gt;

&lt;p&gt;Now that you know the ins and outs of the useState Hook, you can use it in your code with ease. Just remember that using State is only for values that are expected to change during the component's life. If not expected to change, you can freely use props to pass data from the parent component to the child component. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding (:&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>The Destructuring Assignment</title>
      <dc:creator>Stephanie Sison</dc:creator>
      <pubDate>Mon, 13 Jun 2022 05:35:45 +0000</pubDate>
      <link>https://dev.to/stejosi/the-destructuring-assignment-n54</link>
      <guid>https://dev.to/stejosi/the-destructuring-assignment-n54</guid>
      <description>&lt;p&gt;Here is a fun one to learn and is such an efficient thing to use when coding in JavaScript. It is actually one of the things I learned in bootcamp that I fully understood just reading the lesson before doing the lab assigned to it. &lt;/p&gt;

&lt;p&gt;It is the Destructuting Assignment. This allows you to pick and choose elements out of a collection and assign variables to it without having to loop around and create a new declaration. It is super efficient because we can very clearly tell JavaScript what we want to pull out of the collection; whether it be an Object, Array, or String, plus the added aesthetic of it in our code because of its simplicity. All with the added bonus of less typing for our poor fingers. &lt;/p&gt;

&lt;p&gt;Using the &lt;strong&gt;Destructuring Assignment&lt;/strong&gt; to assign data to variables, you will want to put {curly braces} around the objects you would like to assign. For this one, the order inside the curly braces does not matter because we are looking for attributes by their key names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mooMoo = {
name: 'Alfred',
type: 'Hairy Cow',
color: 'tan and white',
};

const {name, color} = mooMoo;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the given data structure above, the curly braces tells Javascript that we will be pulling variables from an &lt;strong&gt;Object&lt;/strong&gt;. We are telling it to pull the keys: 'name' and 'color.' If it exists in 'mooMoo,' then to return the variable associated with that key. Naturally, we will get 'Alfred' for the name key and 'tan and white' for the color key. Heads up, this works for nested Objects as well. You would use method chaining to specify the path you want JavaScript to go down. &lt;/p&gt;

&lt;p&gt;Now, when using Destructuring Assignment with Arrays, you will want to wrap the variables you are declaring in [brackets]. With doing this, the order does matter, so be sure you put the order you are declaring properly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const farmAnimals = ['chicken', 'cow', 'pig'];
const [small, large, medium] = farmAnimals;
console.log(large, small, medium); // LOG: cow chicken pig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The console assigns small to the first element, the large element to the second element, and medium to the third element. The fun part is you can pick parts of the Array we want to assign by using a comma.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const farmAnimals = ['chicken', 'cow', 'pig'];
const [, large, medium] = farmAnimals;
console.log(, small, medium); // LOG: chicken pig

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

&lt;/div&gt;



&lt;p&gt;When we use a comma, we are telling JavaScript to skip the first element and start with the second element. You can also move the comma to different spots to skip that element. &lt;/p&gt;

&lt;p&gt;And finally, when using Destructuring Assignment with Strings, we will be using the .split() method to turn the string into an Array. You will also be using [brackets] to wrap the variables you'd like to assign.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cowName = 'Prince Alfred Kingston III';
const [title, firstName] = cowName.split(' ');
console.log(title, firstName); // LOG Prince Alfred
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now a very important part of using split() in a &lt;strong&gt;Destructuring Assignment&lt;/strong&gt; is the 'single quotes' in the (parenthesis). You only make that mistake once otherwise it drives you mad trying to figure out what is wrong with your code. &lt;/p&gt;

&lt;p&gt;Doesn't the Destructuring Assignment sound so fun? In no time you'll learn just how to use it and be a pro. And trust me, it will save you so much time and typing in your code.&lt;/p&gt;

&lt;p&gt;Happy Coding (:&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>The Wonderful World of JavaScript Scopes</title>
      <dc:creator>Stephanie Sison</dc:creator>
      <pubDate>Mon, 06 Jun 2022 22:29:00 +0000</pubDate>
      <link>https://dev.to/stejosi/the-wonderful-world-of-javascript-scopes-2c29</link>
      <guid>https://dev.to/stejosi/the-wonderful-world-of-javascript-scopes-2c29</guid>
      <description>&lt;p&gt;Understanding the three levels of Scope in JavaScript is very important. Once you have a better grasp on what can access each level of Scope, it makes life so much easier. &lt;/p&gt;

&lt;p&gt;Let's think of this like those blocks that you played with as a kid. You know the ones that get smaller in size and can fit into each one to create just one box. Say you have three boxes. Box #1 is a little bigger than box #2, box #2 is a little bigger than box #3, and box #3 is the smallest of them all. Box #3 can fit into box #2, and then box #2 can fit into box #1 to create just one box. But box #1 cannot fit inside box #3. JavaScript works similarly. The different level of scopes can only be accessed through one direction and not the other.&lt;/p&gt;

&lt;p&gt;Now that you have the images of those confusing boxes in your head, I can tell you about the Scopes of JavaScript. &lt;/p&gt;

&lt;p&gt;You start off with the &lt;strong&gt;Global&lt;/strong&gt; scope. This is similar to box number 1. With box #1 being the outer box that holds all the smaller boxes, Global scope is the outer scope. It can be accessed in every level of scope. If a variable is not declared inside a function or block scope, it is automatically part of the Global scope and it can now be referenced by anything in the code. This can be declared by using [const], [let], or [var]. Declaring a variable in a Global scope is not necessarily frowned upon, but it is much preferred for it to be in a functional or block scope. Only declare a variable via Global scope if you know for a fact that you need to be able to access it multiple times in your code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const globalNum = 25;

function mathFunc() {
   return globalNum * 2 
} 

mathFunc()
// =&amp;gt; 50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see from the above example, the globalNum can be accessed inside the mathFunc() with no problem and return the answer of '50' when mathFunc() is called.&lt;/p&gt;

&lt;p&gt;Now we move on to box #2 or the &lt;strong&gt;Functional&lt;/strong&gt; scope. A variable declared in the functional scope is specific to that function. Only that function has access to that variable. [const], [let], and [var] are keywords that can be used in a Functional scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruit = 'Apple'

function greens() {
  const vegetable = 'Spinach'

  console.log('fruit:', fruit)
  console.log('vegetable:', vegetable)
  console.log('sour:', sour)
}

function candy() {
  const sour = 'Airheads'

  console.log('fruit:', fruit)
  console.log('sour:', sour)
  console.log('vegetable:', vegetable)
}

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greens();
// LOG: fruit: Apple
// LOG: vegetable: Spinach
// ERROR: Uncaught ReferenceError: sour is not defined

candy();
// LOG: fruit: Apple
// LOG: sour: Airheads
// ERROR: Uncaught ReferenceError: vegetable is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see that both functions are allowed access to the fruit variable because it is in the &lt;strong&gt;Global Scope&lt;/strong&gt;. But, because 'vegetable' is only declared in the &lt;strong&gt;greens()&lt;/strong&gt;, the &lt;strong&gt;sour()&lt;/strong&gt; is not able to have access to them. Which is why when we try to console log the variable &lt;em&gt;sour&lt;/em&gt; in the &lt;strong&gt;greens()&lt;/strong&gt; results in an &lt;strong&gt;ERROR&lt;/strong&gt;. The same thing happens when we try to console log the variable &lt;em&gt;greens&lt;/em&gt; in the &lt;strong&gt;sour()&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And finally, box #3 or the &lt;strong&gt;Block&lt;/strong&gt; scope. A Block scope is everything within a statement. It is very specific to that block and only has access to things inside its' block. Variables are typically declared in curly braces &lt;strong&gt;{ }&lt;/strong&gt;. Anything declared in the curly braces cannot be accessed outside of the block. The common keywords for a Block scope is [const] or [let]. The keyword [var] cannot be Block scoped because it does not follow the lexical pattern. It gives you access outside of block scope, but not global scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myNum() {
   if(true) {
     let x = 100
     console.log('block:', x)
   } 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we call this function, it will allow us to console log x and return the value of it because we are using console.log inside the same brackets of the block scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myNum()
// block: x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if we were to try to move the console log outside of the block scope, we would get an error because we are trying to access the variable 'x' from outside of the block scope. 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;function myNum() {
   if(true) {
     let x = 100
   } 
console.log('block:', x)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myNum()
// ERROR : ReferenceError: x is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By simply moving the console log outside of the block scope parameters, the system will give us a &lt;strong&gt;ERROR&lt;/strong&gt; Message. &lt;/p&gt;

&lt;p&gt;Just like the box reference, you can only fit one inside another. The levels of scope can be accessed from down to up and not vice versa. The &lt;strong&gt;Global&lt;/strong&gt; scope can be accessed by the &lt;strong&gt;Functional&lt;/strong&gt; and &lt;strong&gt;Block&lt;/strong&gt; scopes. The &lt;strong&gt;Functional&lt;/strong&gt; scope can be accessed by the &lt;strong&gt;Block&lt;/strong&gt; scope. And the &lt;strong&gt;Block&lt;/strong&gt; scope only has access to itself. In a simplified version, the outer scope does not have access to variables declared in an inner scope. The inner scope, however, does have access to the outer scopes. &lt;/p&gt;

&lt;p&gt;What matters the most in the scope chain, is where the variable is declared, not where it is invoked.&lt;/p&gt;

&lt;p&gt;I hope my analogy made sense to you as it did to me. I find with as much information that we are currently learning, it is nice to relate it to something else to make sense of it all. Happy coding ya'll (: &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Assigning and Declaring Values and Variables</title>
      <dc:creator>Stephanie Sison</dc:creator>
      <pubDate>Mon, 06 Jun 2022 22:21:00 +0000</pubDate>
      <link>https://dev.to/stejosi/assigning-and-declaring-values-and-variables-2k0a</link>
      <guid>https://dev.to/stejosi/assigning-and-declaring-values-and-variables-2k0a</guid>
      <description>&lt;p&gt;As a current student learning how to code via JavaScript with little to no experience in the coding world even the simplest things can be thought of to be complicated. I found so far that I sometimes like to make things harder than it seems to be. For example, using &lt;code&gt;let&lt;/code&gt; vs. &lt;code&gt;const.&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Some background information before we continue. &lt;code&gt;Let&lt;/code&gt; and &lt;code&gt;Const&lt;/code&gt; was introduced in 2015 when the ECMAScript 6 came out with the updates. ECMAScript or ES was created by developers to be a centralized organization to allow changes or additions in languages like JavaScript. The idea behind this organization is to add updates in an organized manner. Allowing one group to control what is updated to be used with the new language keeps the languages organized and efficient.&lt;/p&gt;

&lt;p&gt;Before the introduction of &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;, there was &lt;code&gt;var&lt;/code&gt;. The keyword &lt;code&gt;var&lt;/code&gt; is one that is used in older browsers as it was part of the ECMAScript1 update. Since the ES6 update, &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are the preferred uses when declaring a variable. And to go further on those lines, my instructor have strongly advised me to declare variables primarily using the keyword &lt;code&gt;const&lt;/code&gt;. By declaring variables using &lt;code&gt;const&lt;/code&gt;, it prevents you from accidentally re-declaring it later on in your code. And when you are working on a big project, will save you many headaches. &lt;/p&gt;

&lt;p&gt;I did the pre-work that was assigned to me before starting my current program. I felt like I had this down, but when it came down to doing my first assignment with it in the actual program, I found it more difficult than it really needed to be. After researching and reading up on &lt;code&gt;let&lt;/code&gt; vs. &lt;code&gt;const,&lt;/code&gt; I finally realized that a value assigned to &lt;code&gt;let&lt;/code&gt; is something that can be modified and that a value assigned to &lt;code&gt;const&lt;/code&gt; is something you cannot.&lt;/p&gt;

&lt;p&gt;Someone had mentioned to me to think of &lt;code&gt;let&lt;/code&gt; as "reading and writing." It is something that you can follow, but also make changes to as necessary. Now think of &lt;code&gt;const&lt;/code&gt; as "reading." It is something that cannot be erased nor changed once a value has been assigned to it. &lt;/p&gt;

&lt;p&gt;Somehow this analogy is now stuck in my brain every time I come to a point where I need to use &lt;code&gt;let&lt;/code&gt; or &lt;code&gt;const.&lt;/code&gt; I will silently question myself whether or not I need "read and write" this value or just "read" it.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Hello internet friends ...</title>
      <dc:creator>Stephanie Sison</dc:creator>
      <pubDate>Sun, 22 May 2022 16:28:42 +0000</pubDate>
      <link>https://dev.to/stejosi/hello-internet-friends--2n3m</link>
      <guid>https://dev.to/stejosi/hello-internet-friends--2n3m</guid>
      <description>&lt;p&gt;My name is Stephanie. I live in Washington and I am currently a hairdresser. I was born in the Philippines and moved to the states when I was 4 years old. Although, we lived in the states and adapted to some of the customs here, my mother also found it very important to keep our native culture embedded in us. I can speak tagalog and english. And fun fact, I am one of 14 kids - long story short, that's step-siblings, half-siblings, and full siblings. &lt;/p&gt;

&lt;p&gt;I have been in the hair industry about five and half years and have been itching for a change. I started my career change journey by doing some pre-requisites for nursing and found that that was not the right path for me. I have loads of clients, given that I work at a salon in Seattle, in the tech world and they have graciously let me pick their brains. I found it so interesting. A friend introduced me to the bootcamp route and I started off learning on freecodecamp.org as I am sure that plenty of people have started on. It worked my brain and really challenged it, but I loved every second of it. It was so amazing to code something and then see the outcome of it right away and the abundance of things you can do to them. &lt;/p&gt;

&lt;p&gt;Flatiron stood out to me because of their Flex program. Because I took some community college classes that were primarily online, I found myself accustomed to the online learning and working full time. I really admire the help Flatiron offers even being in the Flex Software Engineer program because I can learn on my own pace, but I am always able to get help if I need it. I would love to learn more about front end because I like seeing the code that I create come to life. I really enjoyed the pre-work assignment where we re-created the Pharrell Williams poster. Aside from that, I would really be interested in getting into a gaming company and code for them. But all around, I love being a part of the tech world since it changes and evolves everyday and I have a small part in that. &lt;/p&gt;

&lt;p&gt;I can't wait for you all to follow along my journey and read about what I learned. I am so excited for this new chapter in my life and I am taking everything in, no matter how challenging, with open arms.&lt;/p&gt;

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