<?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: Priya Kothalkar</title>
    <description>The latest articles on DEV Community by Priya Kothalkar (@kothalkarpriya).</description>
    <link>https://dev.to/kothalkarpriya</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%2F681684%2F37ee6cd2-1936-4fc6-a650-14a03aece953.jpeg</url>
      <title>DEV Community: Priya Kothalkar</title>
      <link>https://dev.to/kothalkarpriya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kothalkarpriya"/>
    <language>en</language>
    <item>
      <title>I Replaced 10 useStates with One useReducer (ft. HackerRank Challenge)</title>
      <dc:creator>Priya Kothalkar</dc:creator>
      <pubDate>Sun, 20 Jul 2025 21:20:18 +0000</pubDate>
      <link>https://dev.to/kothalkarpriya/i-replaced-10-usestates-with-one-usereducer-ft-hackerrank-challenge-2lo1</link>
      <guid>https://dev.to/kothalkarpriya/i-replaced-10-usestates-with-one-usereducer-ft-hackerrank-challenge-2lo1</guid>
      <description>&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;Today, I came across a challenge on hackerRank, focused on State management and it turned out to be interesting + to test my Basics!&lt;br&gt;
&lt;a href="https://www.hackerrank.com/challenges/code-review-feedback/problem?isFullScreen=true" rel="noopener noreferrer"&gt;Link to the HackerRank Challenge&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the details: &lt;br&gt;
We have 5 different feedback cards labelled as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Readability&lt;/li&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each card has 2 buttons as Upvote and Downvote.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Goal:
&lt;/h3&gt;

&lt;p&gt;All cards should render together, but each card must manage its upvote/downvote count separately, without affecting the others. Along with it, they should pass the tests on HackerRank.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clicking &lt;strong&gt;Upvote&lt;/strong&gt; on a card should increase that card’s upvote count by 1&lt;/li&gt;
&lt;li&gt;Clicking &lt;strong&gt;Downvote&lt;/strong&gt; should increas that card’s downvote count by 1&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each card is independent, and the count should reflect it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's explore the Solution:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution 1: Use 10 individual &lt;code&gt;useState&lt;/code&gt; Hooks.&lt;/strong&gt;&lt;br&gt;
Here, I’d maintain a separate state for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each card’s upvotes (5 total)&lt;/li&gt;
&lt;li&gt;Each card’s downvotes (5 total)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [readabilityUp, setReadabilityUp] = useState(0);
const [readabilityDown, setReadabilityDown] = useState(0);
// ...and so on for the other 4 cards
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Simple to implement&lt;/li&gt;
&lt;li&gt;Easy to follow for beginners&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Not scalable — 10 states for just 5 cards!&lt;/li&gt;
&lt;li&gt;Becomes messy with more feedback types&lt;/li&gt;
&lt;li&gt;Logic is duplicated across cards&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution 2: Using &lt;code&gt;useReducer&lt;/code&gt; for centralised state&lt;/strong&gt;&lt;br&gt;
Instead of managing 10 different states, I centralized state handling using a reducer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initial State:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const initialState = {
  Readability: { upvote: 0, downvote: 0 },
  Performance: { upvote: 0, downvote: 0 },
  Security: { upvote: 0, downvote: 0 },
  Documentation: { upvote: 0, downvote: 0 },
  Testing: { upvote: 0, downvote: 0 },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Reducer Logic:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function reducer(state, action) {
  const { card, votetype } = action.payload;
  switch (votetype) {
    case "upvote":
      return {
        ...state,
        [card]: {
          ...state[card],
          [votetype]: state[card][votetype] + 1
        }
      };
    case "downvote":
      return {
        ...state,
        [card]: {
          ...state[card],
          [votetype]: state[card][votetype] + 1
        }
      };
    default:
      return state;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Scalable and clean&lt;/li&gt;
&lt;li&gt;Centralised state handling&lt;/li&gt;
&lt;li&gt;DRY (Don't Repeat Yourself) principle applied&lt;/li&gt;
&lt;li&gt;Easier to debug and maintain&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Slightly more advanced if you're new to React&lt;/li&gt;
&lt;li&gt;Requires understanding of reducers and dispatching actions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;My Learning &amp;amp; Takeaways&lt;/strong&gt;&lt;br&gt;
I started with &lt;code&gt;useState&lt;/code&gt;, but then realised it isn't maintainable and Scalable. Once I refactored using &lt;code&gt;useReducer&lt;/code&gt;, the entire structure became cleaner, modular, scalable and better!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What I learned:&lt;/strong&gt;&lt;br&gt;
Think beyond “just getting it to work”, consider scalability and maintainability.&lt;br&gt;
&lt;code&gt;useReducer&lt;/code&gt; is a great fit when managing multiple related states. Even simple UI components can challenge your architecture choices&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Final Thoughts:
&lt;/h3&gt;

&lt;p&gt;This small challenge helped me rethink how I approach state in React.&lt;br&gt;
It was more than just fixing a UI; it became an exercise in writing cleaner, scalable code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Would love to hear how you would have solved this! Let’s discuss 💬&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>devchallenge</category>
      <category>react</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Understanding React hooks</title>
      <dc:creator>Priya Kothalkar</dc:creator>
      <pubDate>Sat, 04 Jun 2022 10:27:53 +0000</pubDate>
      <link>https://dev.to/kothalkarpriya/do-you-know-hooks-in-react-4pg9</link>
      <guid>https://dev.to/kothalkarpriya/do-you-know-hooks-in-react-4pg9</guid>
      <description>&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Table of Content:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;What are Hooks&lt;/li&gt;
&lt;li&gt;State as a Hook&lt;/li&gt;
&lt;li&gt;Effect as a Hook&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you want to learn about hooks from the basics then this blog will be helpful to you. So, let's understand what is hooks? and how we can use them in our Projects. &lt;/p&gt;

&lt;blockquote&gt;

&lt;h3 id="what-are-hooks"&gt;What are Hooks&lt;h3&gt;
&lt;/h3&gt;
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hooks are functions that let you use React state and other react features without writing a class. Hook does not work inside classes but lets you use React without classes. &lt;br&gt;
We are going to look at some of the built-in React Hooks such as useState and useEffect.&lt;br&gt;
With Hooks, we can extract stateful logic from a component so it can be tested independently and reused.&lt;/p&gt;



&lt;blockquote&gt;

&lt;h3 id="state-as-a-hook"&gt;State as a Hook&lt;h3&gt;
&lt;/h3&gt;
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;We have an example counter here. After every click on the button the counter increments the value:&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";

export default function App() {
  const [counter, setCounter] = useState(0);
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;You clicked counter {counter} times&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCounter(counter + 1)}&amp;gt;Click me&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code gives us the output as follows:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DhHzpdrmnAQ"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;em&gt;useState&lt;/em&gt; is a Hook. We call it inside a function to add some local state to it. React preserve this state between re-renders. &lt;em&gt;useState&lt;/em&gt; return a pair of the current state and a function that let us update the state. We can call this function using an event handler or somewhere else. &lt;br&gt;
&lt;em&gt;useState&lt;/em&gt; takes only one argument as its initial state. In this example 0 is our initial state and using this our counter starts at zero. You can change as per your need. The initial state argument is used only at the initial render.&lt;br&gt;
We can also use a state hook more than once in a single component.&lt;/p&gt;



&lt;blockquote&gt;

&lt;h3 id="effect-as-a-hook"&gt;Effect as a Hook&lt;h3&gt;
&lt;/h3&gt;
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;em&gt;useEffect&lt;/em&gt; hook, adds the ability to perform side effects from a function component. As we can manually change the DOM from React component because it can't be done during rendering. By default, React runs the &lt;em&gt;useEffect&lt;/em&gt; hook after every render including the first render.&lt;br&gt;
For Example, the below example sets the Document title after React updates the DOM:&lt;br&gt;
&lt;/p&gt;

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

export default function App() {
  const [counter, setCounter] = useState(0);
  useEffect(() =&amp;gt; {
    document.title = `Counter: ${counter} time`;
  });
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;You clicked counter {counter} times&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCounter(counter + 1)}&amp;gt;Click me&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code gives us the output as follows:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/H6suUTh4Zbg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;I hope you have understood what is Hooks and how to use them. We will learn how to create our custom hooks in the next blog which will be updated soon. If you have any suggestions regarding the blog, please let me know in the comments section.&lt;/p&gt;

&lt;h4&gt;
  
  
  Thank you!
&lt;/h4&gt;

</description>
      <category>react</category>
      <category>hooks</category>
      <category>webdev</category>
      <category>blog</category>
    </item>
    <item>
      <title>Understanding em, rem, px, vh, vw, and % conventions</title>
      <dc:creator>Priya Kothalkar</dc:creator>
      <pubDate>Tue, 10 May 2022 17:42:33 +0000</pubDate>
      <link>https://dev.to/kothalkarpriya/understanding-em-rem-px-vh-vw-and-conventions-1e8a</link>
      <guid>https://dev.to/kothalkarpriya/understanding-em-rem-px-vh-vw-and-conventions-1e8a</guid>
      <description>&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Table of Content:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;em&lt;/li&gt;
&lt;li&gt;rem&lt;/li&gt;
&lt;li&gt;px and %&lt;/li&gt;
&lt;li&gt;vh and vw&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;We are using frequently some of the conventions in CSS to style our elements. Sometimes we use px, rem, em, and so on. But did you think what are they doing? How our elements are getting different sizes using them? Yeah, we have questions Don't we? So I wanted to summarize the answer to it efficiently! So what are you waiting for let's dive into the concept!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;em: Relative to the parent's size&lt;/li&gt;
&lt;li&gt;rem: based on the root size (1rem = 16px)&lt;/li&gt;
&lt;li&gt;px: it defines size in pixel (1px = 0.0625 rem)&lt;/li&gt;
&lt;li&gt;vh: 1% of viewport height&lt;/li&gt;
&lt;li&gt;vw: 1% of viewport width&lt;/li&gt;
&lt;li&gt;%: Relative to parent's size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's understand using examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example1:&lt;/strong&gt; Using em&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3 id="em"&gt;em is a relative length unit, which is relative to parent size.&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;HTML&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul class="ems li"&amp;gt;
   &amp;lt;li&amp;gt;First&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Second&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Third
       &amp;lt;ul&amp;gt;
           &amp;lt;li&amp;gt;Third A&amp;lt;/li&amp;gt;
           &amp;lt;li&amp;gt;Third B
               &amp;lt;ul&amp;gt;
                   &amp;lt;li&amp;gt;Third B 2&amp;lt;/li&amp;gt;
               &amp;lt;/ul&amp;gt;
           &amp;lt;/li&amp;gt;
       &amp;lt;/ul&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;CSS&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html{
    font-size: 16px;
}
.ems li{
    font-size: 1.3em;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will give us the output:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfwgz7bmgbjnzbp4bbw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfwgz7bmgbjnzbp4bbw5.png" alt="Exampleoneoutput"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here, we have applied em to every list inside class ems. So, As "First" has a font-size: 1.3em, the next "First A" is having font-size 1.3 times to parent size. And so on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example2:&lt;/strong&gt; Using rem&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3 id="rem"&gt;rem is a relative length unit, which is relative to the root's size&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;HTML&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul class="rems li"&amp;gt;
   &amp;lt;li&amp;gt;First&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Second&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Third
       &amp;lt;ul&amp;gt;
           &amp;lt;li&amp;gt;Third A&amp;lt;/li&amp;gt;
           &amp;lt;li&amp;gt;Third B
               &amp;lt;ul&amp;gt;
                   &amp;lt;li&amp;gt;Third B 2&amp;lt;/li&amp;gt;
               &amp;lt;/ul&amp;gt;
            &amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;CSS&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html{
    font-size: 16px;
}
.rems li{
    font-size: 1.5rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It gives us the output:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fherrhahn5u7dqukaxfsx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fherrhahn5u7dqukaxfsx.png" alt="Exampletwooutput"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As rem is relative to root font-size and we have given html as font-size 16px so each list element having 16px font-size.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example3:&lt;/strong&gt; Using px and % (percentage)&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3 id="px-and-percent"&gt;Pixel-px is an absolute length unit that is not relative to anything else and is always the same size.&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;HTML&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="box"&amp;gt;
    &amp;lt;p&amp;gt;I am a using pixel&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class="box"&amp;gt;
    &amp;lt;p class="para"&amp;gt;I am using percentage&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;CSS&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    color:white;
    border:2px solid black;
    margin:1rem;
}
.box p{
    margin: 0;
    width: 200px;
    background-color: purple;
    padding: 1rem;
}
.box .para{
    width:20%;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will give us the output:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxirz6omyq74knzdz179h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxirz6omyq74knzdz179h.png" alt="ExampleThreeOutput"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pixel is independently accessing its 200px and % is dependent on div block, so it's accessing the 20% of div block size.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example4:&lt;/strong&gt; Using Vh(Viewport's Height) and Vw (Viewport's width)&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3 id="vh-and-vw"&gt;vh and vw are relative length units that are relative to the viewport.&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;HTML&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="block Vh"&amp;gt;I am 10 vh long&amp;lt;/div&amp;gt;
&amp;lt;div class="block Vw"&amp;gt;I am 10vw wide&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;CSS&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.block{
    background-color: aqua;
    margin:1rem;
    border: 2px solid black;
}
.Vh{
    width:10vh;
}
.Vw{
    width: 10vw;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03ayu3lzwkni2qoqvbli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03ayu3lzwkni2qoqvbli.png" alt="ExampleFourOutput"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As shown in the output you will see, 10vh is equals to 100px and 10vw is equals to 120px for viewport of 1200px width and 1000px height.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;So, It's completed! I hope you will find this helpful and if there are any suggestions please write in the comments.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank You!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Understanding Temporal Dead Zone!</title>
      <dc:creator>Priya Kothalkar</dc:creator>
      <pubDate>Sun, 06 Mar 2022 12:52:36 +0000</pubDate>
      <link>https://dev.to/kothalkarpriya/understanding-temporal-dead-zone-5gjm</link>
      <guid>https://dev.to/kothalkarpriya/understanding-temporal-dead-zone-5gjm</guid>
      <description>&lt;p&gt;Temporal Dead Zone is the area of a &lt;strong&gt;block&lt;/strong&gt; where a variable is not accessible till it gets initialized with a value.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Block is pair of brackets {...} used to group multiple executable statements&lt;/li&gt;
&lt;li&gt;Initialization means assigning an initial value to a variable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we try to access the variable before its initialization, it will throw a Reference error as shown below:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JRf2Hbr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk6kui52i9wn7dlb2ixi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JRf2Hbr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk6kui52i9wn7dlb2ixi.png" alt="Image showing reference error" width="607" height="63"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As you can see we got ReferenceError stating can't access the variable before initialization. To prevent our Javascript code from such kind Errors, we need to access variables outside the Temporal Dead Zone(TZD).&lt;/p&gt;

&lt;h4&gt;
  
  
  Scope of Temporal Dead Zone:
&lt;/h4&gt;

&lt;p&gt;TDZ starts at the beginning of the block's local scope and ends with the variable initialization with 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;{
  // tdz of block started
  // tdz of block started
  console.log(a); // Reference Error
  // tdz continued
  // tdz continued
  let a = 20; // tdz ends here
  // tdz does not exist here
  // tdz does not exist here
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see that this started at the start of the {}(brackets/block) itself and ended with the variable initialization. &lt;br&gt;
We got a Reference error because we tried accessing the variable before its initialization. So, it's a good practice to access variables after initialization.&lt;/p&gt;

&lt;h5&gt;
  
  
  Let's take examples to better understand the concept:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Example 1:
Accessing variables after declaration and before initialization
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;The above code gives us the output as &lt;em&gt;undefined&lt;/em&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_LxsJdhU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ue3sn58dy7xdlp2g3t57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_LxsJdhU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ue3sn58dy7xdlp2g3t57.png" alt="output-undefined" width="592" height="71"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The output shows that we have that variable but do not have any value assigned yet, so the compiler gives it an undefined value.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example 2:
As we know if we try to access a variable before its definition and initialization it will give a reference error.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JRf2Hbr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk6kui52i9wn7dlb2ixi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JRf2Hbr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk6kui52i9wn7dlb2ixi.png" alt="Image showing reference error" width="607" height="63"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Example 3:
If we use var to declare a variable we get undefined as output, as we try to access the variable before initialization.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(add);
var add = 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--25RKeD3a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4ljzllbmjc8dcbpvbf7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--25RKeD3a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4ljzllbmjc8dcbpvbf7.png" alt="var-output-undefined" width="403" height="66"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Javascript does not initialize let and const variables with any values, they remain dead and inaccessible.  In contrast, var is initialized after its hoisting.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nowadays &lt;strong&gt;let&lt;/strong&gt; and &lt;strong&gt;const&lt;/strong&gt; are used instead of var to define variables as it causes minimum consequences.In old scripts only we would be able to see var used.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My Portfolio</title>
      <dc:creator>Priya Kothalkar</dc:creator>
      <pubDate>Mon, 16 Aug 2021 06:15:21 +0000</pubDate>
      <link>https://dev.to/kothalkarpriya/my-portfolio-24b5</link>
      <guid>https://dev.to/kothalkarpriya/my-portfolio-24b5</guid>
      <description>&lt;p&gt;My #Portfolio contains Projects, Blogs, Skills and Social media links.&lt;br&gt;
&lt;a href="https://priya-kothalkar.netlify.app/"&gt;https://priya-kothalkar.netlify.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can have a look, and if you have any suggestions please let me know in comments.&lt;br&gt;
Thank you!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>html</category>
      <category>css</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
