<?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>Forem: tanzirulhuda</title>
    <description>The latest articles on Forem by tanzirulhuda (@tanzirulhuda).</description>
    <link>https://forem.com/tanzirulhuda</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%2F609788%2F9fc008da-704c-466b-af3a-86c53e80f946.png</url>
      <title>Forem: tanzirulhuda</title>
      <link>https://forem.com/tanzirulhuda</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tanzirulhuda"/>
    <language>en</language>
    <item>
      <title>I built an AI-powered code explainer</title>
      <dc:creator>tanzirulhuda</dc:creator>
      <pubDate>Tue, 18 Apr 2023 21:32:44 +0000</pubDate>
      <link>https://forem.com/tanzirulhuda/i-built-an-ai-powered-code-explainer-3n0o</link>
      <guid>https://forem.com/tanzirulhuda/i-built-an-ai-powered-code-explainer-3n0o</guid>
      <description>&lt;p&gt;Hello everyone! 👋&lt;/p&gt;

&lt;p&gt;I'm excited to share with you my latest project, &lt;a href="https://virtuo.simplef.net/"&gt;Virtuo&lt;/a&gt;! It's an AI-powered Chrome extension that makes accessing ChatGPT a breeze - no more switching between different tabs! And for all you programmers out there, I've added a new feature that allows you to easily get explanations of any code in a friendly and easy-to-understand tone.&lt;/p&gt;

&lt;p&gt;I recently tweeted about Virtuo, and you can check it out here: &lt;a href="https://twitter.com/tanzirul_huda/status/1648401244074164224?s=20"&gt;https://twitter.com/tanzirul_huda/status/1648401244074164224?s=20&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know, you could always just copy the code and ask ChatGPT, but I wanted to make it even easier for you. With &lt;a href="https://virtuo.simplef.net/"&gt;Virtuo&lt;/a&gt;, you don't have to switch between tabs or ask with proper prompts. You can get the answers you need right from the tab you're browsing! ⚡&lt;/p&gt;

</description>
      <category>programming</category>
      <category>chatgpt</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JavaScript Hack 1- Use of console.table()</title>
      <dc:creator>tanzirulhuda</dc:creator>
      <pubDate>Sat, 22 Oct 2022 08:11:33 +0000</pubDate>
      <link>https://forem.com/tanzirulhuda/javascript-hack-1-use-of-consoletable-3f0b</link>
      <guid>https://forem.com/tanzirulhuda/javascript-hack-1-use-of-consoletable-3f0b</guid>
      <description>&lt;p&gt;JavaScript is really a cool language. It has some awesome features that we should know. In this article, we are gonna see something really cool which is maybe you didn't see before.&lt;/p&gt;

&lt;h2&gt;
  
  
  console.table()
&lt;/h2&gt;

&lt;p&gt;This awesome method will help you to CSV or dictionary format data in a table.&lt;br&gt;
It takes one mandatory data which is must be an array.It will return you a table of this array. Every element of the array will be a row of table.&lt;/p&gt;

&lt;p&gt;Let's have a look of it-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Store data in an array
var data = ['Mercedes', 'Tesla', 'Rolls Royce', 'BMW'];

//Output
console.table(data);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's move forward. Now we're gonna display an object in this method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// An array of object

function Car(brand, ceo){
    this.brand = brand;
    this.ceo = ceo;
}

const mercedes = new Car('Mercedes', 'Ola Källenius');
const tesla= new Car('Tesla', 'Elon Musk');
const rollsRoyce = new Car('Rolls Royce', 'Warren East');
const bmw= new Car('BMW', 'Harald Krüger');

//Output
console.table([mercedes, tesla, rollsRoyce, bmw])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Isn't it cool? I hope you enjoy this. Feel free to leave a comment and also share &amp;amp; ❤️ it.&lt;/p&gt;

&lt;p&gt;You can follow me:)&lt;br&gt;
&lt;a href="https://twitter.com/tanzirul_huda"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding🧑‍💻!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Use Filters with Arrays</title>
      <dc:creator>tanzirulhuda</dc:creator>
      <pubDate>Wed, 19 Oct 2022 09:06:21 +0000</pubDate>
      <link>https://forem.com/tanzirulhuda/how-to-use-filters-with-arrays-pd8</link>
      <guid>https://forem.com/tanzirulhuda/how-to-use-filters-with-arrays-pd8</guid>
      <description>&lt;p&gt;Filtering an array is useful when you’re working with multiple columns of corresponding data. In this case, you can include and exclude data based on any characteristic that describes a group in your array.&lt;br&gt;
To filter an array, use the filter() function.&lt;br&gt;
Example snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cars = [
  { make: 'Opel', class: 'Regular' },
  { make: 'Bugatti', class: 'Supercar' },
  { make: 'Ferrari', class: 'Supercar' },
  { make: 'Ford', class: 'Regular' },
  { make: 'Honda', class: 'Regular' },
]
const supercar = cars.filter(car =&amp;gt; car.class === 'Supercar');
console.table(supercar); // returns the supercar class data in a table format
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use filter() together with Boolean to remove all null or undefined values from your array.&lt;/p&gt;

&lt;p&gt;Example snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cars = [
  { make: 'Opel', class: 'Regular' },
  null,
  undefined
]

cars.filter(Boolean); // returns [{ make: 'Opel', class: 'Regular' }] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay! Thanks for reading. Happy coding!&lt;br&gt;
You can follow me:&lt;br&gt;
&lt;a href="https://twitter.com/tanzirul_huda"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Learn JS by building a stop watch</title>
      <dc:creator>tanzirulhuda</dc:creator>
      <pubDate>Tue, 18 Oct 2022 08:13:41 +0000</pubDate>
      <link>https://forem.com/tanzirulhuda/learn-js-by-building-a-stop-watch-4k25</link>
      <guid>https://forem.com/tanzirulhuda/learn-js-by-building-a-stop-watch-4k25</guid>
      <description>&lt;p&gt;In todays tutorial, we'll create a &lt;strong&gt;stop watch&lt;/strong&gt; as the first project. The special thing about this stopwatch is that you can count hours, minutes, seconds and milliseconds here. However, we'll do this work in 2 steps. First of all we'll design a simple interface using HTML and CSS. Then we'll make it functional.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML &amp;amp; CSS
&lt;/h2&gt;

&lt;p&gt;At first, let's create a basic container for our stop watch.&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%2Ft32dao2bj1g00t9dmars.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%2Ft32dao2bj1g00t9dmars.png" alt="Basic HTML for the container of stop watch"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, let's add some basic style in it. &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%2Fmun8oeorn58ucau1uver.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%2Fmun8oeorn58ucau1uver.png" alt="Basic CSS Style"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay, let's move to the next. Now, we'll create a display so that all the time can be seen.&lt;/p&gt;

&lt;p&gt;Add a new div with the class name of &lt;strong&gt;display&lt;/strong&gt; like below,&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%2F6ffl4gp95kkbuydhxuy2.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%2F6ffl4gp95kkbuydhxuy2.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, let's add some style for it so that it can get a pretty look.&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%2Fz20bi7w96q9usaj4b53r.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%2Fz20bi7w96q9usaj4b53r.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you done it? Great! Now we'll create 3 buttons in our HTML code and then we'll make it functional using JavaScript.&lt;/p&gt;

&lt;p&gt;For now, let's create the buttons. And add some style in it.&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%2F8hsdlhoi5j9iajbgpde2.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%2F8hsdlhoi5j9iajbgpde2.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add some CSS in our stylesheet like below.&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%2Fdt1dk87s8arvubkd6a7r.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%2Fdt1dk87s8arvubkd6a7r.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you done? Now, it's time to implement some functionality using JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  JavaScript
&lt;/h2&gt;

&lt;p&gt;First we'll collect some information using let. Such asset is a constant of display id and holds 0 for hours, minutes, seconds, and milliseconds.&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%2F66cbgz3n8yvys0sw9x5d.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%2F66cbgz3n8yvys0sw9x5d.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, we'll create three function for start, pause, and reset the timer. &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%2Fpfkvv5aeuvobk91or1qz.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%2Fpfkvv5aeuvobk91or1qz.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we'll create a function that is already I used in the function to start the timer, &lt;strong&gt;dispayTimer&lt;/strong&gt;. Now we have to create this function so that when you click on start button to start the stop watch then it can be able to start the countdown.&lt;br&gt;
Don't worry, I'll give you a explanation that what am I doing here.&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%2Fmtei4bnr2gdvqsbh1hgj.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%2Fmtei4bnr2gdvqsbh1hgj.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Explanations: *&lt;/em&gt;&lt;br&gt;
You can see that I used three "if" functions here. In the first 'if' function, I added a condition that if milliseconds is equal to 1000 then milliseconds value is 0 and seconds is incremented by 1.&lt;/p&gt;

&lt;p&gt;➤ We know that 1 second equals 1000 milliseconds. So when the milliseconds value reaches 1000 after the countdown, the milliseconds value is zero and the seconds value is incremented by 1.&lt;/p&gt;

&lt;p&gt;➤ Similarly, we used the second "if" function for time in seconds. We know that 1 minute equals 60 seconds. So if the seconds value equals 60, the seconds time is 0 and the minutes cell is incremented by 1.&lt;/p&gt;

&lt;p&gt;➤ We know that 1 hour equals 60 minutes. So when the hour in minutes reaches 60, the minute cell is 0 and the hour cell is incremented.&lt;/p&gt;

&lt;p&gt;This is how the countdown timer continues.&lt;/p&gt;

&lt;p&gt;Now, we'll add a zero before each single digit point. Displays a number if the time is less than 10. we'll add a zero to each of these single digit numbers using the following four line code: If the hour, minute, second, and millisecond values ​​are less than 10, zeros are added before those hours.&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%2Fh3jd1am4oneai05u0gmc.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%2Fh3jd1am4oneai05u0gmc.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have to arrange all this information in the display using innerHTML. As above, the hours, minutes, seconds, and milliseconds are stored between h, m, s, and ms, respectively.&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%2Fvc5ar27vtsj0vmy9b5th.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%2Fvc5ar27vtsj0vmy9b5th.png" alt="Tanzirul Huda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you done it! Congratulations, you just made a stop watch using basic JavaScript.&lt;/p&gt;

&lt;p&gt;By the way, if you face any problem you can see the complete JavaScript code below-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let [milliseconds,seconds,minutes,hours] = [0,0,0,0];
let timerRef = document.querySelector('.display');
let int = null;

document.getElementById('startTimer').addEventListener('click', ()=&amp;gt;{
    if(int!==null){
        clearInterval(int);
    }
    int = setInterval(displayTimer,10);
});

document.getElementById('pauseTimer').addEventListener('click', ()=&amp;gt;{
    clearInterval(int);
});

document.getElementById('resetTimer').addEventListener('click', ()=&amp;gt;{
    clearInterval(int);
    [milliseconds,seconds,minutes,hours] = [0,0,0,0];
    timerRef.innerHTML = '00 : 00 : 00 : 000 ';
});

function displayTimer(){
    milliseconds+=10;
    if(milliseconds == 1000){
        milliseconds = 0;
        seconds++;
        if(seconds == 60){
            seconds = 0;
            minutes++;
            if(minutes == 60){
                minutes = 0;
                hours++;
            }
        }
    }

 let h = hours &amp;lt; 10 ? "0" + hours : hours;
 let m = minutes &amp;lt; 10 ? "0" + minutes : minutes;
 let s = seconds &amp;lt; 10 ? "0" + seconds : seconds;
 let ms = milliseconds &amp;lt; 10 ? "00" + milliseconds : milliseconds &amp;lt; 100 ? "0" + milliseconds : milliseconds;

 timerRef.innerHTML = ` ${h} : ${m} : ${s} : ${ms}`;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this tutorial has taught you how to create a simple JavaScript stopwatch make sense about JavaScript too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect with me
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://twitter.com/tanzirul_huda" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;br&gt;
Happy coding!&lt;/p&gt;

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