<?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: Devarshi Bhojak</title>
    <description>The latest articles on DEV Community by Devarshi Bhojak (@sirdev108).</description>
    <link>https://dev.to/sirdev108</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%2F384546%2Ff1c1b0b4-f1f7-44b6-baaf-7ec42f070373.jpg</url>
      <title>DEV Community: Devarshi Bhojak</title>
      <link>https://dev.to/sirdev108</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sirdev108"/>
    <language>en</language>
    <item>
      <title>The Art of Debugging &amp; Most Common Bugs</title>
      <dc:creator>Devarshi Bhojak</dc:creator>
      <pubDate>Sat, 27 Feb 2021 08:34:38 +0000</pubDate>
      <link>https://dev.to/sirdev108/the-art-of-debugging-most-common-bugs-3jpj</link>
      <guid>https://dev.to/sirdev108/the-art-of-debugging-most-common-bugs-3jpj</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k34RUQ4o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614339637470/x_rTZdPRg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k34RUQ4o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614339637470/x_rTZdPRg.jpeg" alt="bugs-in-the-code.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://devcamp.com/site_blogs/top-5-programming-memes"&gt;source&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Debugging&lt;/em&gt; is the process of removing bugs and errors from your code. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Syntax errors&lt;/strong&gt;: Stops code from running.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Runtime errors&lt;/strong&gt;: Where your code has unexpected behaviour.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logical errors&lt;/strong&gt;: Where your code doesn't do what you intended.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;In the fight against bugs, the console is your best friend.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Following are some of the common bugs we encounter every day.&lt;/p&gt;

&lt;h3&gt;
  
  
  Missing Parenthesis, strings.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum() {
 let p = 6;
 let q = 3;
 return p + q;
}

let ans = sum;
console.log(ans);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Answer&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;function sum() {
 let p = 6;
 let q = 3;
 return p + q;
}

let ans = sum();
console.log(ans);

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Arguments in the Wrong Order.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function raiseToPower(b, e) {
 return Math.pow(b, e);
}

let base = 2;
let exp = 3;
let power = raiseToPower(exp, base);
console.log(power);//9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Answer&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;function raiseToPower(b, e) {
  return Math.pow(b, e);
}

let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);//8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Off By One Error.
&lt;/h3&gt;

&lt;p&gt;Indexing in JS starts at zero, not one, which means the last index is always one less than the length of the item.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let string = "Thisirhgebuggystrig";
let length = string.length;
for (let i = 0; i &amp;lt;= length; i++) {
  // loops one too many times at the end
  console.log(string[i]);
}
for (let j = 1; j &amp;lt; length; j++) {
  // loops one too few times and misses the first character at index 0
  console.log(string[j]);
}
for (let k = 0; k &amp;lt; length; k++) {
  // This is just right
  console.log(string[k]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are just a fraction of many bugs you will face while learning to code and building projects. However, do not let any bug stop you from coding. The knowledge you gain after finding the solution is worthwhile. &lt;/p&gt;

&lt;p&gt;Check out this breathtaking &lt;a href="https://softwareengineeringdaily.com/2016/11/19/debugging-stories-with-haseeb-qureshi/"&gt;bug story &lt;/a&gt; (SE DAILY podcast).&lt;/p&gt;

&lt;p&gt;You can find me at  &lt;a href="https://twitter.com/DEVARSHI_1"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This blog is inspired by &lt;a href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/#debugging"&gt;FreeCodeCamp&lt;/a&gt; debugging section.&lt;/p&gt;

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