<?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: Anuj Srivastav</title>
    <description>The latest articles on DEV Community by Anuj Srivastav (@anuj8126).</description>
    <link>https://dev.to/anuj8126</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%2F318019%2F85b29811-d356-48a5-a041-4d288a18956f.jpeg</url>
      <title>DEV Community: Anuj Srivastav</title>
      <link>https://dev.to/anuj8126</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anuj8126"/>
    <language>en</language>
    <item>
      <title>Git Commands Every Developer Should Know</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Wed, 19 Jul 2023 19:59:02 +0000</pubDate>
      <link>https://dev.to/anuj8126/git-commands-every-developer-should-know-50pp</link>
      <guid>https://dev.to/anuj8126/git-commands-every-developer-should-know-50pp</guid>
      <description>&lt;p&gt;Git is a powerful version control system that has become an integral part of modern software development. Whether you are a beginner or an experienced developer, understanding and mastering essential Git commands is crucial for efficient collaboration, code management, and tracking changes. In this blog, we will explore some of the most commonly used Git commands and how they can streamline your development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Essential Git Commands
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Initializing a Repository:&lt;/strong&gt;&lt;br&gt;
To start using Git, you first need to create a new repository or clone an existing one. The following commands help you set up a new repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git init&lt;/code&gt;: Initializes a new Git repository in the current directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git clone &amp;lt;repository-url&amp;gt;&lt;/code&gt;: Clones an existing repository from a remote server to your local machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Basic Configuration:&lt;/strong&gt;&lt;br&gt;
Before you start committing code, it's essential to set your identity in Git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git config --global user.name "Your Name"&lt;/code&gt;: Set your name for all commits.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git config --global user.email "youremail@example.com"&lt;/code&gt;: Set your email for all commits.
**&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adding and Committing Changes:**&lt;br&gt;
The heart of Git is its ability to track and manage changes to your code. To save changes to the repository, use the following commands:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;git status&lt;/code&gt;: Shows the status of your repository, including changed files and untracked files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;git add &amp;lt;file-name&amp;gt;&lt;/code&gt;: Adds a specific file to the staging area to be included in the next commit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt;: Adds all changes in the working directory to the staging area.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;git commit -m "Commit message"&lt;/code&gt;: Commits the changes in the staging area with a descriptive message.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Branching and Merging:&lt;/strong&gt;&lt;br&gt;
Git allows you to work on separate branches to develop new features or fix bugs without affecting the main codebase. Use the following commands to manage branches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt;: Lists all branches in the repository, highlighting the current branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch &amp;lt;branch-name&amp;gt;&lt;/code&gt;: Creates a new branch with the given name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout &amp;lt;branch-name&amp;gt;&lt;/code&gt;: Switches to the specified branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git merge &amp;lt;branch-name&amp;gt;&lt;/code&gt;: Merges the changes from the specified branch into the current branch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Updating and Synchronizing:&lt;/strong&gt;&lt;br&gt;
To keep your local repository up to date with the remote repository and vice versa, use these commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git pull&lt;/code&gt;: Fetches and merges changes from the remote repository to your local branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push&lt;/code&gt;: Pushes your local commits to the remote repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Viewing History and Differences:&lt;/strong&gt;&lt;br&gt;
Git provides tools to review changes and commit history:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt;: Shows a detailed commit history, including author, date, and commit message.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git diff&lt;/code&gt;: Displays the differences between the working directory and the staging area.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git diff &amp;lt;commit-id-1&amp;gt; &amp;lt;commit-id-2&amp;gt;&lt;/code&gt;: Shows the differences between two specific commits.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advanced Git Commands for Efficient Version Control
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Git Rebase:&lt;/strong&gt;&lt;br&gt;
Git rebase is a powerful command used to integrate changes from one branch to another by moving or combining commits. It allows you to maintain a linear commit history and avoid the complexities of merge commits. Use the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git rebase &amp;lt;branch-name&amp;gt;&lt;/code&gt;: Rebases the current branch onto the specified branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git rebase -i &amp;lt;commit-id&amp;gt;&lt;/code&gt;: Interactive rebase that lets you squash, reword, or reorder commits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Git Cherry-Pick:&lt;/strong&gt;&lt;br&gt;
Cherry-picking allows you to apply a specific commit from one branch to another. It is useful when you need to add a single commit from a different branch without merging the entire branch. Use the following command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git cherry-pick &amp;lt;commit-id&amp;gt;&lt;/code&gt;: Applies the specified commit to the current branch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Git Stash:&lt;/strong&gt;&lt;br&gt;
When you need to switch to a different branch but have uncommitted changes in your current branch, you can use Git stash to save your changes temporarily. Use the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git stash&lt;/code&gt;: Stashes your changes, saving them for later use.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash apply&lt;/code&gt;: Applies the most recent stash to the current branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash pop&lt;/code&gt;: Applies the most recent stash and removes it from the stash list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Git Reflog:&lt;/strong&gt;&lt;br&gt;
The Git reflog keeps a record of all changes made to the repository, including commits, checkouts, and resets. It is a safety net that helps you recover lost or deleted commits. Use the following command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git reflog&lt;/code&gt;: Displays the history of all Git actions in the repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Git Bisect:&lt;/strong&gt;&lt;br&gt;
Git bisect is a powerful command used to perform a binary search through the commit history to find the exact commit that introduced a bug. It is an effective way to identify the root cause of issues. Use the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git bisect start&lt;/code&gt;: Initiates the binary search process.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git bisect bad&lt;/code&gt;: Marks the current commit as a bad (buggy) commit.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git bisect good &amp;lt;commit-id&amp;gt;&lt;/code&gt;: Marks the specified commit as a good (working) commit.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git bisect reset&lt;/code&gt;: Exits the bisect session.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Git Submodules:&lt;/strong&gt;&lt;br&gt;
Git submodules allow you to include one Git repository as a subdirectory of another repository. This is useful for managing dependencies and integrating external projects. Use the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git submodule add &amp;lt;repository-url&amp;gt; &amp;lt;destination-path&amp;gt;&lt;/code&gt;: Adds a new submodule to the parent repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git submodule update&lt;/code&gt;: Initializes and updates submodules after cloning the parent repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note : Remember to use these commands judiciously and always create backups or use Git branches when experimenting with code changes. Happy coding and version controlling!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why SVG over Other Image formats?</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Wed, 01 Mar 2023 14:29:30 +0000</pubDate>
      <link>https://dev.to/anuj8126/why-svg-over-other-image-formats-2041</link>
      <guid>https://dev.to/anuj8126/why-svg-over-other-image-formats-2041</guid>
      <description>&lt;p&gt;SVG (Scalable Vector Graphics) is a popular image format that offers several advantages over other image formats like PNG, JPEG, and GIF. Here are some reasons why SVG is preferred over other image formats:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: SVG images are vector graphics, which means they can be scaled up or down without losing quality. This is because SVG images are created using mathematical equations, rather than a fixed grid of pixels like raster images. This makes SVG ideal for logos, icons, and other graphics that need to be displayed at various sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Small file size&lt;/strong&gt;: SVG files are typically smaller in size compared to raster image formats like PNG and JPEG. This is because SVG files are written in XML code, which is much more compact than pixel-based image data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retina display support&lt;/strong&gt;: SVG images are resolution-independent, which means they look crisp and clear on high-resolution screens like Retina displays. This is because SVG images can be scaled up to match the screen's resolution without losing quality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;: SVG images can be easily customized and manipulated using CSS, making them more accessible for users with disabilities. For example, SVG images can be easily inverted or made to change color on hover, which can be helpful for users with low vision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Animation&lt;/strong&gt;: SVG images can also be animated using CSS or JavaScript, which can add interactivity and visual interest to web pages. This can be especially useful for creating interactive infographics, charts, or diagrams.&lt;/p&gt;

&lt;p&gt;Overall, SVG is a versatile and flexible image format that offers several advantages over other image formats, making it a popular choice for web designers and developers.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What CHAT GPT Resume Tips for Frontend Developers</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Wed, 01 Mar 2023 14:16:41 +0000</pubDate>
      <link>https://dev.to/anuj8126/what-chat-gpt-resume-tips-for-frontend-developers-2h3o</link>
      <guid>https://dev.to/anuj8126/what-chat-gpt-resume-tips-for-frontend-developers-2h3o</guid>
      <description>&lt;p&gt;As a frontend developer, you want to make sure that your resume highlights your skills and experience in a way that catches the attention of potential employers. &lt;strong&gt;Recently asked to chat GPT for Tips about Frontend Development here what Chat GPT says&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Start with a strong summary: Begin your resume with a brief summary that highlights your key skills and experience. This will help to grab the attention of potential employers and encourage them to keep reading.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Focus on your technical skills: As a frontend developer, your technical skills are what set you apart. Make sure to highlight your experience with programming languages such as HTML, CSS, and JavaScript, as well as any frameworks or libraries you are proficient in (e.g., React, Angular, Vue).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Showcase your projects: One of the best ways to demonstrate your skills as a frontend developer is to showcase your projects. Include a section in your resume that lists some of your most impressive projects, along with details on the technologies you used and your role in the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Highlight your design skills: As a frontend developer, you are also responsible for creating visually appealing designs. Make sure to highlight any experience you have with design tools such as Sketch or Adobe Creative Suite, and include examples of designs you have created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Emphasize your teamwork and collaboration skills: Frontend development often involves working closely with designers, backend developers, and other team members. Highlight your experience working on collaborative projects and your ability to work effectively in a team environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use action verbs: When describing your experience and accomplishments, use action verbs to make your statements more dynamic and engaging. For example, instead of saying "worked on a project," say "led the development of a project."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep it concise: Employers are often inundated with resumes, so make sure yours is easy to read and to the point. Use bullet points to break up large blocks of text, and keep your resume to no more than two pages.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these tips, you can create a strong resume that highlights your skills and experience as a frontend developer and makes you stand out to potential employers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here Adding Some Side Projects Repo to improve your FrontEnd Knowledge -
&lt;/h2&gt;

&lt;p&gt;RSS (React Server Side Rendering) demo&lt;br&gt;
Github: &lt;a href="https://github.com/Absolutestunna/React-Server-Side" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/React-Server-Side&lt;/a&gt;&lt;br&gt;
Blog-Backend (Server/DB integration, ongoing) – RESTful API endpoints and database storage solution.&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/blog-backend" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/blog-backend&lt;/a&gt;&lt;br&gt;
WriterSpace (web app, on-going) – blogging web app for writers.&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/writerSpace" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/writerSpace&lt;/a&gt;&lt;br&gt;
Coffee Uncrowned (website) – Curated list of coffee shops in major cities.&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/responsive-website" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/responsive-website&lt;/a&gt;&lt;br&gt;
Live code: &lt;a href="http://absolutestunna.github.io/responsive-website/" rel="noopener noreferrer"&gt;http://absolutestunna.github.io/responsive-website/&lt;/a&gt;&lt;br&gt;
Sk8 Shop (website) – Responsive Web Design for a skate shop&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/IY-2.8-SK8" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/IY-2.8-SK8&lt;/a&gt;&lt;br&gt;
Live Code: &lt;a href="http://absolutestunna.github.io/IY-2.8-SK8/" rel="noopener noreferrer"&gt;http://absolutestunna.github.io/IY-2.8-SK8/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github Recreate (website) - Responsive websites&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/github" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Live Code: &lt;a href="http://absolutestunna.github.io/github" rel="noopener noreferrer"&gt;http://absolutestunna.github.io/github&lt;/a&gt;&lt;br&gt;
Clima (mobile, on-going)&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/Clima" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/Clima&lt;/a&gt;&lt;br&gt;
Restaurant (website)&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/Absolutestunna/IY-7.4-Resturant" rel="noopener noreferrer"&gt;https://github.com/Absolutestunna/IY-7.4-Resturant&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>architecture</category>
      <category>security</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Javascript Rest vs Spread Operator - What's the difference?</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Wed, 01 Mar 2023 13:59:28 +0000</pubDate>
      <link>https://dev.to/anuj8126/javascript-rest-vs-spread-operator-whats-the-difference-2aab</link>
      <guid>https://dev.to/anuj8126/javascript-rest-vs-spread-operator-whats-the-difference-2aab</guid>
      <description>&lt;p&gt;&lt;strong&gt;In JavaScript, the rest and spread operators are both denoted by the same three dots (...) syntax, but they are used in different contexts and have different effects.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The rest operator is used in a function's parameter list to represent an indefinite number of arguments passed to the function. It allows you to pass a variable number of arguments to a function and handle them as an array inside the function. Here's an example:&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;function&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&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="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// output: 6&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;In this example, the ...numbers parameter in the sum function's parameter list represents an indefinite number of arguments that can be passed to the function. The rest operator collects all the arguments into an array called numbers.&lt;/p&gt;

&lt;p&gt;On the other hand, the spread operator is used to spread the elements of an iterable (such as an array) into another iterable (such as an array or an object). Here's an example:&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;arr1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&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="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// output: [4, 5, 1, 2, 3]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;In this example, the spread operator (...arr1) is used to spread the elements of arr1 into arr2. This results in a new array (arr2) that contains all the elements of arr1 followed by 4 and 5.&lt;/p&gt;

&lt;p&gt;In summary, the rest operator is used to collect a variable number of arguments into an array in a function's parameter list, while the spread operator is used to spread the elements of an iterable into another iterable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The main difference between two is -&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;rest operator&lt;/strong&gt; is used to fill a JavaScript array &lt;br&gt;
with the remaining data from a user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The JavaScript &lt;strong&gt;spread operator&lt;/strong&gt; allows an array or an &lt;br&gt;
object to be spread or flattened into its elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In common terms We can say -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Rest we use for pack elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spread we use for unpack elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Leet Code - Longest Common Prefix</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Tue, 26 Jul 2022 20:23:00 +0000</pubDate>
      <link>https://dev.to/anuj8126/leet-code-longest-common-prefix-onf</link>
      <guid>https://dev.to/anuj8126/leet-code-longest-common-prefix-onf</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Write a function to find the longest common prefix string amongst an array of strings.&lt;br&gt;
If there is no common prefix, return an empty string "".&lt;/p&gt;
&lt;h2&gt;
  
  
  Algorithm
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;if array is empty, return a prefix of empty string Or if &lt;br&gt;
array has 1 word, return the whole word.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iterate through letter of first word of Array , and compare &lt;br&gt;
those letters to same Indexed letter to other world.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   let strs = ["flower","flow","flight"]
   So What above line meaning is -
   str[0][0] === str[1][0],
   str[0][1] === str[1][1] and so on....  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;if the letters match continue to next set of letters &lt;br&gt;
otherwise return the prefix&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the letter is no longer matching then the first word &lt;br&gt;
will mark where the longest common prefix is, so &lt;br&gt;
we add to our empty string.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;First Try to Solve Problem using Algorithm&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Javascript Function for Longest Common Prefix
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @param {string[]} strs
 * @return {string}
 */&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;longestCommonPrefix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&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="c1"&gt;//array is empty, return a prefix of empty string&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//array has 1 word, return the whole word&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;

&lt;span class="c1"&gt;//Iterate through letter of first word of Array&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="c1"&gt;//compare those letters to same Indexed letter to other world.&lt;/span&gt;
 &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]){&lt;/span&gt;
     &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/*If the letter is no longer matching then the first word 
  will mark where the longest common prefix is, so 
  we add to our empty string*/&lt;/span&gt;
&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;strs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&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;h2&gt;
  
  
  Test Cases
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Input: strs = ["flower","flow","flight"]&lt;br&gt;
Output: "fl"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: strs = ["dog","racecar","car"]&lt;br&gt;
Output: ""&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: strs = ["",""]&lt;br&gt;
Output: ""&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Leet Code - Integer to Roman Numeral Function in JavaScript</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Sat, 23 Jul 2022 12:12:00 +0000</pubDate>
      <link>https://dev.to/anuj8126/leet-code-integer-to-roman-numeral-function-in-javascript-55n4</link>
      <guid>https://dev.to/anuj8126/leet-code-integer-to-roman-numeral-function-in-javascript-55n4</guid>
      <description>&lt;h2&gt;
  
  
  Algorithm
&lt;/h2&gt;

&lt;p&gt;for decimal number &lt;strong&gt;X&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Object for each symbol as key and it's respective
value
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const roman = {
    M: 1000,
    CM: 900,
    D: 500,
    CD: 400,
    C: 100,
    XC: 90,
    L: 50,
    XL: 40,
    X: 10,
    IX: 9,
    V: 5,
    IV: 4,
    I: 1
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;find the highest decimal value &lt;strong&gt;V&lt;/strong&gt; that is less than or &lt;br&gt;
equal to the decimal number &lt;strong&gt;X&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Store the Roman numeral that you found after Subtracting &lt;br&gt;
it's value &lt;strong&gt;V&lt;/strong&gt; from &lt;strong&gt;X&lt;/strong&gt; &lt;br&gt;
&lt;code&gt;X = X - V&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repeat above  Process until you get zero of &lt;strong&gt;X&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;X = 36&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bhgm5dyanzd5zov7wbt.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%2F4bhgm5dyanzd5zov7wbt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Javascript Function to Covert Integer to Roman Numeral
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/**
 * @param {number} num
 * @return {string}
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;roman&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;M&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;CM&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;D&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;CD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;C&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;XC&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;L&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;XL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;X&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;IX&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;V&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;IV&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;I&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;intToRoman&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;result&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="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;roman&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;roman&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;roman&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="nf"&gt;intToRoman&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;intToRoman&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test Cases :
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Input: num = 3&lt;br&gt;
Output: "III"&lt;br&gt;
Explanation: 3 is represented as 3 ones.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: num = 58&lt;br&gt;
Output: "LVIII"&lt;br&gt;
Explanation: L = 50, V = 5, III = 3.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: num = 1994&lt;br&gt;
Output: "MCMXCIV"&lt;br&gt;
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Leet Code - Roman Numeral to Integer Function in JavaScript</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Fri, 15 Jul 2022 21:41:00 +0000</pubDate>
      <link>https://dev.to/anuj8126/leet-code-roman-numeral-to-integer-function-in-javascript-2o58</link>
      <guid>https://dev.to/anuj8126/leet-code-roman-numeral-to-integer-function-in-javascript-2o58</guid>
      <description>&lt;h2&gt;
  
  
  Algorithm
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a Object for each symbol as key and it's respective &lt;br&gt;
value&lt;br&gt;
&lt;code&gt;const romanobj = {&lt;br&gt;
I      :     1,&lt;br&gt;
V      :     5,&lt;br&gt;
X      :     10,&lt;br&gt;
L      :     50,&lt;br&gt;
C      :     100,&lt;br&gt;
D      :     500,&lt;br&gt;
M      :     1000&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Split the Roman Numeral string into Roman Symbols or in different  word split string into Characters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Take a Symbol from Starting from 0 index&lt;br&gt;
1). If current value of symbol is greater than or equal to &lt;br&gt;
  the value of next symbol, then add this value to the &lt;br&gt;
  total.&lt;br&gt;
2). else subtract this value by adding the value of next &lt;br&gt;
  symbol to the total. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Javascript Function to Covert Roman Numeral to Integer
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @param {string} s
 * @return {number}
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="na"&gt;I&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;V&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;X&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;L&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;C&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;D&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;M&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;1000&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;romanToInt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]){&lt;/span&gt;
 &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;
&lt;span class="nx"&gt;i&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;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&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;h2&gt;
  
  
  Test Cases
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Input: s = "III"&lt;br&gt;
Output: 3&lt;br&gt;
Explanation: III = 3.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: s = "MCMXCIV"&lt;br&gt;
Output: 1994&lt;br&gt;
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>LeetCode — Valid Parentheses</title>
      <dc:creator>Anuj Srivastav</dc:creator>
      <pubDate>Wed, 13 Jul 2022 20:49:00 +0000</pubDate>
      <link>https://dev.to/anuj8126/leetcode-valid-parentheses-44a4</link>
      <guid>https://dev.to/anuj8126/leetcode-valid-parentheses-44a4</guid>
      <description>&lt;p&gt;Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;isValid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bracketObj&lt;/span&gt; &lt;span class="o"&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;{&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;}&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;(&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;)&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;[&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;]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
   &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bracketObj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()]&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]){&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&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;strong&gt;Test Cases Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: s = "()"&lt;br&gt;
Output: true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: s = "()[]{}"&lt;br&gt;
Output: true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: s = "(]"&lt;br&gt;
Output: false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Input: s = "([)]"&lt;br&gt;
Output: false&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&lt;br&gt;
&lt;/code&gt;Input: s = "(("&lt;br&gt;
Output: false`&lt;br&gt;
**&lt;br&gt;
CodeSandBox Link **&lt;br&gt;
&lt;a href="https://dev.tourl"&gt;&lt;br&gt;
https://codesandbox.io/s/valid-parentheses-1gs732?file=/src/index.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>challenge</category>
    </item>
  </channel>
</rss>
