<?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: prachigarg19</title>
    <description>The latest articles on DEV Community by prachigarg19 (@prachigarg19).</description>
    <link>https://dev.to/prachigarg19</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%2F723458%2Fcab44de9-17a1-4f73-a375-52062cf0fd33.png</url>
      <title>DEV Community: prachigarg19</title>
      <link>https://dev.to/prachigarg19</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prachigarg19"/>
    <language>en</language>
    <item>
      <title>Project 10: Press shift to check multiple boxes</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Sat, 11 Dec 2021 18:17:17 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-10-1100</link>
      <guid>https://dev.to/prachigarg19/project-10-1100</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 10 and project 10. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 10 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Final result:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;In this project we will focus on how to select multiple checkboxes by using shift.This is a very common features in website now a days. You can further add features to this and create a to-do-list project. &lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/prachigarg19/embed/jOGMggK?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30"&gt;My source code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  PART 1:HTML
&lt;/h2&gt;

&lt;p&gt;I've used a little bootstrap here. All you have to do is go to &lt;a href="https://getbootstrap.com/docs/5.1/forms/input-group/"&gt;Bootstrap input groups&lt;/a&gt; and copy paste the code for checkbox along with input field format or you could copy it from my codepen. I wanted to focus on the js part for this challenge.&lt;br&gt;
As you can see I've created input group and the thing to notice here is that I've given same id and class to radio and text box respectively.You will see it's use later.&lt;/p&gt;
&lt;h2&gt;
  
  
  PART 2:CSS
&lt;/h2&gt;

&lt;p&gt;Now we are going to style our project.&lt;br&gt;
Here we have just made checkbox and text input box inline. We have also centered the container horizontally and vertically.&lt;/p&gt;
&lt;h2&gt;
  
  
  PART 3:JAVASCRIPT
&lt;/h2&gt;

&lt;p&gt;The idea is to check all the items between last checked item and the one clicked after pressing shift.&lt;br&gt;
Now we will simply check for click event on radioboxes and call linethrough function for each element. &lt;/p&gt;

&lt;p&gt;linethrough function will simply set the style of the id element to line-through.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function linethrough(id){
    value=id;
    document.querySelector(`.${value}`).style="text-decoration:line-through";
    console.log(value)
}

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

&lt;/div&gt;



&lt;p&gt;We will store id of checked element only if flag is false. This is used to make sure shift hasn't been pressed by user before checking radiobox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(radio of radioboxes){

    radio.addEventListener('click',(e)=&amp;gt;{
        id=e.target.id;
        linethrough(id);
        if(flag==false) last=e.target.id;
        //flag=false means shift is not pressed hence value of last is updated.
    })

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

&lt;/div&gt;



&lt;p&gt;If user presses shift then we will handle it separately.&lt;/p&gt;

&lt;p&gt;Let' handle the shift case now. The idea is that we will store the id of the radio checked by user and then call linethrough function for each item.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.addEventListener('keydown',(e)=&amp;gt;{
    if(e.key==='Shift')
    {   flag=true; //set flag to true
        Array.from(radioboxes).forEach(radio=&amp;gt;{
            //now we will store the index of radio to the current.
            radio.addEventListener('click',(e)=&amp;gt;{
                current=e.target.id;
                selectMultiple();

            })
        })
    }
})

function selectMultiple(){
    //this will take numeric value in index. 
    currindex=current[current.length-1];
     lastindex=last[last.length-1];
     //start will take the smaller value of both index numeric part. Loop will begin from here
    start=(currindex&amp;lt;lastindex?currindex:lastindex);
    //end takes the larger value
    end=(currindex&amp;gt;lastindex?currindex:lastindex);
    //loop over each element.Check and line through each element.
        for(i=start;i&amp;lt;=end;i++)
        { id=`group-${i}`;
          document.getElementById(`${id}`).checked=true;
           linethrough(id);
        }  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since our index is of format group-1,group-2 etc so we will take the last char of these strings to use them to compare their values and to iterate through loop.&lt;br&gt;
Since user can click above or below the previously checked element, so we will initiate the smaller value to start and larger to end ,to iterate through loop. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Things I learnt:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;I didn't learn anything new as such, but this one was a bit tricky as compared to previous ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Previous article from this series:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-9-must-know-dev-tools-tricks-1lb6"&gt;Day 9 Project 9&lt;/a&gt;, in this project I discussed about some dev tool tricks that one should know about. Do check it out if you haven't yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be HTML5 Video Player.&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>Project 9: Must Know Dev Tools Tricks</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Thu, 09 Dec 2021 18:36:52 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-9-must-know-dev-tools-tricks-1lb6</link>
      <guid>https://dev.to/prachigarg19/project-9-must-know-dev-tools-tricks-1lb6</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 9 and project 9. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 9 challenge of &lt;a href="https://javascript30.com/" rel="noopener noreferrer"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is a theoretical challenge where we will discuss some helpful dev tool tricks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;Suppose we have javascript on our page and we want to see the js code acting on an element&lt;/u&gt;&lt;/strong&gt; then we can simply select inspect the elements &amp;gt; go to the html code of that element &amp;gt; Right click &amp;gt;Break on&amp;gt; Attribute modification. This will pause our website when js code is implemented on that element and shows that particular line with a dot left to it.This can help a lot when we see websites with large code bases and cannot figure out the js code acting on a element.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Below we will discuss about different types of output that can be printed on console other than our regular console.log. Hope you find these helpful too!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;Ways to print variable values in console-&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a. console.log("My name is %s",'Prachi');&lt;br&gt;
   b. var="Prachi"&lt;br&gt;
     console.log("My name is ${var}");&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;&lt;u&gt;Applying css on our console output-&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
 &lt;code&gt;console.log("%c This is styled text","color:red;font-size:20px");&lt;/code&gt;&lt;br&gt;
&lt;u&gt;First argument&lt;/u&gt;- %c and statement to be printed&lt;br&gt;
&lt;u&gt;Second argument&lt;/u&gt;-css to be applied to the statement.&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%2F64dzl7ocz4uvcs75wtfz.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%2F64dzl7ocz4uvcs75wtfz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;&lt;u&gt;Printing warning message- &lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
console.warn('This is a warning');&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%2Fiitvlwz281jy4n1i8qqs.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%2Fiitvlwz281jy4n1i8qqs.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
It also displays the stack trace from where it was called.&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;&lt;u&gt;Displaying error message:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
console.error('This is a error");&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%2Fw01n7kf58o8ihhn7jxmd.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%2Fw01n7kf58o8ihhn7jxmd.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
It also displays the stack trace from where it was called.&lt;/p&gt;

&lt;p&gt;5.&lt;strong&gt;&lt;u&gt;Displaying statement with an info sign next to it:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
console.info('This is info');&lt;/p&gt;

&lt;p&gt;6.&lt;strong&gt;&lt;u&gt;To check if statement is true or not:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Suppose we want to check if a part of our code is true or not then we can use this trick.&lt;br&gt;
e.g. &lt;u&gt;we want to check is our input has attribute value or not then-&lt;/u&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;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;

      &amp;lt;input type="text" id="text"&amp;gt;
      &amp;lt;script&amp;gt;
       text=document.getElementById('text');
        console.assert(text.hasAttribute('value'),"There is no value attribute");
      &amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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%2Fgs1isq8s3b8bf0tr8zob.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%2Fgs1isq8s3b8bf0tr8zob.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;assert will have 2 arguments, first will contain statement that is to be checked,second will be the statement that we want to print for displaying error. Also, assert shows output ONLY IF STATEMENT IS WRONG.&lt;/p&gt;

&lt;p&gt;7.&lt;strong&gt;&lt;u&gt;Clearing console:&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;console.clear(); &lt;/p&gt;

&lt;p&gt;8.&lt;strong&gt;&lt;u&gt;Displaying all the properties and elements associated with an element:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;console.log(element name);&lt;br&gt;
e.g.&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;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;

     &amp;lt;p id="text"&amp;gt;lorem10&amp;lt;/p&amp;gt;
      &amp;lt;script&amp;gt;
       text=document.getElementById('text');
        console.dir(text);
      &amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&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%2Ffrrp50bl7o03igvh7ceh.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%2Ffrrp50bl7o03igvh7ceh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;9.&lt;strong&gt;&lt;u&gt;Grouping multiple console statements.&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Suppose we want to iterate over our array and group all the statements for better readability,then-&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;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;

      &amp;lt;script&amp;gt;
       let Dogs=[{name:"Mylo",age:2},{name:"Noddy",age:3},{name:"blacky",age:4}];

       for(dog of Dogs)
       {  //naming of group
         console.group(`${dog.name}`);
         console.log(`Hello my name is ${dog.name}`);
         console.log(`I am ${dog.age} years old`);
         //ending group
         console.groupEnd(`${dog.name}`);
       }
      &amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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%2Fu3hvex1rc5wa9r5yigxm.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%2Fu3hvex1rc5wa9r5yigxm.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
We can have different argument value in group and groupEnd.&lt;/p&gt;

&lt;p&gt;Without groupEnd our first group won't end and the next object will be shown as a subgroup of the first group-&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%2Frpf5kd3lvfbeidnz2azk.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%2Frpf5kd3lvfbeidnz2azk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10.&lt;strong&gt;&lt;u&gt;Printing the number of times a particular dom element,statement,variable etc. has been printed on console:&lt;/u&gt;&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;      console.count('Mylo');
      console.count('Noddy'); 
      console.count('Mylo');
      console.count('Mylo');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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%2Fyvb7n3am7wryvj4gtept.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%2Fyvb7n3am7wryvj4gtept.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;Displaying content in table format:&lt;/u&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let Dogs=[{name:"Mylo",age:2},{name:"Noddy",age:3},{name:"blacky",age:4}];
       console.table(Dogs)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;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%2F2yeospi8cflecln20nm6.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%2F2yeospi8cflecln20nm6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;12.&lt;strong&gt;&lt;u&gt;Displaying time taken by a particular set of code.&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
We will use console.time to begin with time recording and console.timeEnd to end recording and displaying time taken.&lt;br&gt;
E.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let Dogs=[{name:"Mylo",age:2},{name:"Noddy",age:3},{name:"blacky",age:4}];

       //start timer
       console.time('Iterating array')
       for(dog of Dogs)
       {  
         console.log(`${dog.name}`);
        }
        //ending and displaying time
       console.timeEnd('Iterating array');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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%2Fm4oot0blztlx8prjld3z.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%2Fm4oot0blztlx8prjld3z.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Also time and timeEnd should have same string otherwise it'll show a warning displaying that the string doesn't exist unlike group and groupEnd where different arguments will work. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Things I learnt:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Almost all the tricks mentioned in this article were new to me.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Previous article from this series:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-8html-5-canvas-7bg"&gt;Day 8 Project 8&lt;/a&gt;, in this project I built a HTML5 canvas. Do check it out if you haven't yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be 'Hold shift to check multiple checkboxes'.&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Project 8:HTML 5 Canvas</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Wed, 08 Dec 2021 18:35:08 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-8html-5-canvas-7bg</link>
      <guid>https://dev.to/prachigarg19/project-8html-5-canvas-7bg</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 8 and project 8. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 8 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Final result:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/prachigarg19/embed/PoJNOZw?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Press rerun to clear canvas.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;ADDED FUNCTIONALITIES:&lt;/u&gt; I have made this project compatible for mouse operated and touch screen devices.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30"&gt;My source code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  PART 1:HTML
&lt;/h2&gt;

&lt;p&gt;Here I've simply used canvas element to create a canvas. The important part is the style added to container. &lt;br&gt;
I'll explain this part in javascript part for better understanding.&lt;/p&gt;
&lt;h2&gt;
  
  
  PART 3:JAVASCRIPT
&lt;/h2&gt;

&lt;p&gt;Now we will make our project interactive.&lt;br&gt;
Initially I've took draw id from dom and have given it a height and width equal to that of window's height and width respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let canvas=document.getElementById('draw');
//setup size of camvas to cover the whole screen
canvas.height=window.innerHeight;
canvas.width=window.innerWidth;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now i will use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext"&gt;getContext&lt;/a&gt; to get the type of content that is returned from canvas. Since we want to create 2d drawings,we'll set it at 2d.&lt;br&gt;
Now I've simply set the properties-&lt;br&gt;
1.&lt;u&gt;setStroke&lt;/u&gt;- It is used to set the color of the stroke that'll be drawn.&lt;br&gt;
2.&lt;u&gt;lineCap&lt;/u&gt;- It sets the shape with which our stroke will start with in the beginning.&lt;br&gt;
3.&lt;u&gt;lineJoin&lt;/u&gt;- It sets the shape at joining point of two lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ctx.strokeStyle=`black`;
ctx.lineJoin='circle';
ctx.lineCap='circle';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will create a flag that will decide whether or not we have to draw strokes or not. We don't want to show unnecessary strokes when user stops touching screen/clicking or user touches anywhere away from canvas.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let flag=false;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initially it is set false as it will set true only if user touches screen/clicks on canvas element.&lt;/p&gt;

&lt;p&gt;Now we will add event listeners on canvas.&lt;br&gt;
&lt;strong&gt;I have used pointer events and not mouse events as shown in course's video to make it compatible for both touch devices/mouse operated devices. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events"&gt;Read more about this event&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1.First action that user will do is simply click/touch on the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;canvas.addEventListener('pointdown',(e)=&amp;gt;{flag=true; 
    [startX,startY]=[e.offsetX,e.offsetY];

    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;startX and startY are the coordinates of the points where user clicks and hence the point user want to begin drawing from. offsets give the coordinates where pointdown was called.&lt;/p&gt;

&lt;p&gt;2.User will move around the canvas. This is where the strokes have to be shown and thus we will call draw function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;canvas.addEventListener('pointmove',draw);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.User will stop touching/clicking canvas or user will click/touch away from canvas. In both these cases we'll set out flag to false as we do not want draw function to be called (No strokes should be drawn)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//if user stops pressing mouse
canvas.addEventListener('pointup',()=&amp;gt;flag=false);
//if user clicks anywhere other than canvas
canvas.addEventListener('pointout',()=&amp;gt;flag=false);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will create draw function-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function draw(e){
    if(flag==false) return;//user is not drawing
    //  setting varying color 
    ctx.strokeStyle=`hsl(${hue},100%,50%)`;
    //start path of stroke
    ctx.beginPath();
    //move to the starting point where user clicked
    ctx.moveTo(startX,startY);
    //draw line till this point 
    ctx.lineTo(e.offsetX,e.offsetY);
    //offset property returns the coordinate at which mouse if clicked. so it will join the line to the point where user keeps moving the mouse.
    ctx.stroke();
    //actually drawing the line between the points

    //setting start points to the last point at which user stopped drawing,without this if draw is triggered then starting point will stick to mousedown offsets only and we want it to start from the point where mouse is being moved currently.
    [startX,startY]=[e.offsetX,e.offsetY];
 //we want color to start from the hue=0 value when it reaches 360.
    hue=(hue&amp;gt;360?0:hue+1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's take the inline css part we talked about in the html part. The pointermove event is fired when a pointer changes coordinates, and the pointer has not been canceled by a browser touch-action. Without touch-action:none browser will cancel our pointermove and so we won't be able to continue our stroke. Setting it to none prevents this problem. &lt;a href="https://stackoverflow.com/questions/48124372/pointermove-event-not-working-with-touch-why-not"&gt;For more info&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Things I learnt:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Literally everything written. 🥴&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Previous article from this series:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-7-array-cardio-day-2-25ln"&gt;Day 7 project 7&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be project 9 where we will discuss about 14 Dev Tool tricks.&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Project 7: Array Cardio Day 2</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Tue, 07 Dec 2021 18:44:40 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-7-array-cardio-day-2-25ln</link>
      <guid>https://dev.to/prachigarg19/project-7-array-cardio-day-2-25ln</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 7 and project 7. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 7 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This challenge was more theoretical rather than implementation. It explained various array prototype methods that I found super helpful and so I'll be explaining each method taught in this challenge and I strongly recommend you to not skip this challenge.&lt;br&gt;
&lt;a href="https://dev.to/prachigarg19/project-4-array-cardio-day-1-3b1k"&gt;Checkout&lt;/a&gt; the first part if you haven't yet.&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'll be linking the documentations I referred for each function to further clear up the topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before proceeding you should be familiar with arrow functions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.some():&lt;/strong&gt; It returns true if at least one element of our array satisfies the test condition of the function passed as a parameter.&lt;br&gt;
e.g. we want to check if any element is divisible by 3.There are 2 ways to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr=[3,4,5,1,8];
let isDivisible=false;
for(item of arr){
    if(item%3==0)
    isDivisible=true;
}

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

&lt;/div&gt;



&lt;p&gt;Now this can be done in a single line using some() method.&lt;br&gt;
It takes a function as a parameter(which will contain our condition), and the parameter function further takes the current element being checked, index(optional) and array on which some is used(optional) as parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr=[3,4,5,1,8];
let isDivisible=arr.some(item=&amp;gt;item%3==0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here item is the current element being checked for its divisbiliy with 3.&lt;/p&gt;

&lt;p&gt;See how code has been reduced to single line.&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some"&gt;Here&lt;/a&gt; is the documentation I read along with the video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.every():&lt;/strong&gt; It is like some(),the difference is that it returns true ONLY IF ALL elements satisfies the condition.&lt;br&gt;
Let's take the same example as above.&lt;br&gt;
Long way-&amp;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 arr=[3,4,5,1,8];
let isDivisible=false;
let count=0;
for(item of arr){
    if(item%3==0)
    count++;
}
isDivisible=(count==5?true:false);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now this whole can be reduced to one line using every().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr=[3,4,5,1,8];
let isDivisible=arr.every(item=&amp;gt;item%3==0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.find():&lt;/strong&gt; It is like &lt;a href="https://dev.to/prachigarg19/project-4-array-cardio-day-1-3b1k"&gt;filter&lt;/a&gt;,the difference is that instead or returning all the elements returning true for the condition,it returns the first element.&lt;/p&gt;

&lt;p&gt;Taking similar example-&lt;br&gt;
Long way-&amp;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 arr=[3,4,5,1,8];
let element;

for(item of arr){
    if(item%3==0)
    {
      element=item;
       break;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;using find() method-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr=[3,4,5,1,8];
let element=arr.find(item=&amp;gt;item%3==0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parameters are similar to all methods mentioned above.&lt;br&gt;
Here is the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.findIndex():&lt;/strong&gt; It returns the first index of the elements satisfying the condition. If no such element exists,-1 is returned.&lt;br&gt;
Let's return the index for the element in above example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr=[3,4,5,1,8];
let index;

for(i=0;i&amp;lt;arr.length;i++){
    if(arr[i]%3==0)
    {
      index=i;
       break;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;using findIndex() function -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr=[3,4,5,1,8];
let index=arr.findIndex(item=&amp;gt;item%3==0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parameters are same as above functions.&lt;/p&gt;

&lt;p&gt;For further understanding, refer &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex"&gt;Documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Things I learnt:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;More Array.prototype methods.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Previous article from this series:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-6ajax-type-ahead-40b3"&gt;Day 6 Project 6&lt;/a&gt;.In this project I built a search filter which is very common feature in website nowadays. Do check it out if you haven't already.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.&lt;br&gt;
These functions as you saw are super handful and will surely help in reducing the line of code.&lt;/p&gt;

&lt;p&gt;Next project will be HTML5 Canvas .&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Project 6:Ajax Type Ahead</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Mon, 06 Dec 2021 18:56:45 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-6ajax-type-ahead-40b3</link>
      <guid>https://dev.to/prachigarg19/project-6ajax-type-ahead-40b3</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 6 and project 6. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 6 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Final result:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;This is a filter for city which is a very common feature in websites nowadays.It will display all the cities that matches the keywords entered by user. &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/prachigarg19/embed/RwLrVdX?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30"&gt;My source code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  PART 1:HTML
&lt;/h2&gt;

&lt;p&gt;Here I've created two divs, container will contain heading and searchbox and second div display-part will display the list according to value entered by user.&lt;/p&gt;

&lt;h2&gt;
  
  
  PART 2:CSS
&lt;/h2&gt;

&lt;p&gt;Now we are going to style our project.Here I've simply used flex on body to center our content. I've also added css to city-list which will contain our list i.e. to be displayed&lt;/p&gt;

&lt;h2&gt;
  
  
  PART 3:JAVASCRIPT
&lt;/h2&gt;

&lt;p&gt;Now we will make our project interactive.&lt;br&gt;
This is the major part of this project. &lt;br&gt;
The idea is to read user's input ,display list of cities matching that input and then display the city selected by user from this list on the input box.We will also highlight the letters entered by user in the list.&lt;/p&gt;

&lt;p&gt;We will first fetch the data from the &lt;a href="const%20url='https://gist.githubusercontent.com/Miserlou/c5cd8364bf9b2420bb29/raw/2bf258763cdddd704f8ffd3ea9a3e81d25e2c6f6/cities.json';"&gt;link&lt;/a&gt; . This link contains our data in json format. We will use fetch function to get data from this link. Also we will use map function &lt;a href="https://dev.to/prachigarg19/project-4-array-cardio-day-1-3b1k"&gt;check this article to know more&lt;/a&gt; to get a new array with just city names and store it in cities variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let data=document.getElementById('text');
// fetching 
let cities;
fetch(url,{
    method:'GET',
})
.then(response=&amp;gt;response.json())
.then(text=&amp;gt;{
    cities=text.map(item=&amp;gt;item['city']);

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will use keyup listener. This event is triggered whenever user enters a key in the element (here textbox). We will then generate regex expression using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp"&gt;regExp&lt;/a&gt; and store all the cities matching this expression into display. We will then call result function to display the list,highlight input by user and changing value in textbox to the value clicked by user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data.addEventListener('keyup',(e)=&amp;gt;{
    if(e.target.value==="") return;
 display=cities.filter(item=&amp;gt;{
     regex=new RegExp(e.target.value,'gi');
     return item.match(regex)

})
result(); //to display list
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;result()--&amp;gt;&lt;/u&gt;&lt;br&gt;
&lt;u&gt;Displaying and highlighting part-&lt;/u&gt;&lt;br&gt;
We will traverse through our display array and store it in a string which will later be appending to our display-part class.&lt;br&gt;
For highlighting, we will replace each item's regex equal part to span part and use inline css to style it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let resultdisplay=document.getElementById('list');
 str="";
    for(let item of display)
    {   let city=item.replace(regex,`&amp;lt;span style="background-color:green;"&amp;gt;${data.value}&amp;lt;/span&amp;gt;`);
        str+=`&amp;lt;ul&amp;gt;&amp;lt;button value="${item}" class="city-list"&amp;gt;${city}&amp;lt;/button&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;hr&amp;gt;`;  
    } 

    resultdisplay.innerHTML=str;

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

&lt;/div&gt;



&lt;p&gt;Notice that I've given a class and value to each list item which will be later used to display city selected by user.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Changing text box display text&lt;/u&gt;&lt;br&gt;
Now we will select all elements with city-list class. We will traverse this list and listen for event on each item. When the user clicks any button the click event will be triggered and we will change value of textbox to the value of the button clicked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try{
    let cityarr=Array.from(document.getElementsByClassName("city-list"));
    for(cityitem of cityarr){
    cityitem.addEventListener('click',(e)=&amp;gt;{
        data.value=e.target.value;
        resultdisplay.innerHTML="";
        //removing list after user chose city
    });}
        }catch(TypeError){
        return;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I've used try-catch block as if user clicks on the highlighted span part the textbox will give TypeError as span html part in result function didn't have a value attribute-&amp;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 city=item.replace(regex,`&amp;lt;span style="background-color:green;"&amp;gt;${data.value}&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we will simply catch this error and return from the loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Things I learnt:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;1.keyup event listener&lt;br&gt;
2.How to highlight part of the list elements.&lt;br&gt;
3.Better understanding of regex.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Previous article from this series:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;First of all thankyou for the great response on my previous article.🥰&lt;br&gt;
If you haven't checked it out here is the link.:&lt;br&gt;
&lt;a href="https://dev.to/prachigarg19/project-5flex-gallery-55jd"&gt;Project 5 day 5&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be Array Cardio day2 .&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Project 5:Flex-gallery</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Sun, 05 Dec 2021 19:12:12 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-5flex-gallery-55jd</link>
      <guid>https://dev.to/prachigarg19/project-5flex-gallery-55jd</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 5 and project 5. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 5 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Final result:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/prachigarg19/embed/XWemPNm?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Set codepen to 0.25x if using small screen devices to see the full result. &lt;br&gt;
&lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30"&gt;My source code&lt;/a&gt;&lt;br&gt;
I've added the images used in the lecture, they aren't included in starter files of this course, so you can download it from my repo. &lt;/p&gt;

&lt;p&gt;As you can see this turned out to be super cute! 😻😌&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  PART 1:HTML
&lt;/h2&gt;

&lt;p&gt;As you can see I've made 5 boxes inside container that will contain our background-image and text.&lt;/p&gt;
&lt;h2&gt;
  
  
  PART 2:CSS
&lt;/h2&gt;

&lt;p&gt;Now we are going to style our project.&lt;br&gt;
This is the main part for this challenge.&lt;br&gt;
First, we want all our boxes to be aligned like shown in result and to achieve this the best way is either grid or flex. I've used flex and aligned them in column direction on container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
    height: 100vh;
    overflow: hidden;
    font-family: 'Amatic SC', cursive;
}

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

&lt;/div&gt;



&lt;p&gt;Now we will go to individual classes and apply background images ,center those images and will set it's size to cover to make it fill the whole container element(individual box classes).&lt;/p&gt;

&lt;p&gt;Then we will simply set font-size for text and set h1 to scale(0) so that it's pushed inside the screen.(This will later on give the 3d look of text coming out of the screen)&lt;/p&gt;

&lt;p&gt;Then I've again applied flex on the box. This is done to position all the heading tags such that they take 3 equal rows using flex:1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    flex:1;
    height: 100vh;
    display:flex;
    flex-direction: column;
    color: #fff;
    justify-content: center;
    align-items: center;
    gap:2em;
    transition: ease-in-out 0.8s;
    text-transform: uppercase;
    flex-wrap: wrap;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I've again applied flex on all the elements of box i.e. h3,h1,h3.This is done to further center the heading tags inside their individual flex. Without this part, translateY won't work as we need to give a wrapper class to the element we want to translate. You can also give classes to the both h3's to achieve this..But flex is used for better positioning of elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box&amp;gt;*{
   display: flex;
   justify-content: center;
   align-items: center;
   flex-direction: column;
   flex:1;
   transition: cubic-bezier(0, 0.95, 0.49, 0.65) 0.8s;


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

&lt;/div&gt;



&lt;p&gt;Then I've taken the first and the last tag and translated them above and below the boxes such that they disappear from the screen. We will later use them to give a sliding effect as shown in result.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box&amp;gt;*:first-child{
    transform: translateY(-100%);
}
/* moving lower h3 down */
.box&amp;gt;*:last-child{
    transform: translateY(100%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I've created a focus class that will increase the size of box user clicked upon by giving it a flex:5. I will later add and remove this class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.focus{
    flex:5;
}

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

&lt;/div&gt;



&lt;p&gt;This is it for css part.&lt;/p&gt;

&lt;h2&gt;
  
  
  PART 3:JAVASCRIPT
&lt;/h2&gt;

&lt;p&gt;Now we will make our project interactive.&lt;/p&gt;

&lt;p&gt;The idea is to traverse all the items with box class, add an event listener which will be called if user clicks on the box and calls out focusImg function.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;focusImg function&lt;/u&gt; --&amp;gt;&lt;br&gt;
Here we will add the class focus to increase the size of container, change the property of translateY to slide our h3's back to the frame.&lt;br&gt;
Also, we want our box to restore back to it's initial state when clicked upon again, to do this we'll simply check if the box element being clicked upon has focus class add to it, if it has that means that it has been clicked by the user before. Now we will simply remove the focus class and remove h3 by using translateY to restore it's initial state.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;em&gt;Things I learnt:&lt;/em&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;1.Nested flex&lt;br&gt;
2.Animation in css.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Previous article from this series:&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-4-array-cardio-day-1-3b1k"&gt;Project 4 Day 4&lt;/a&gt;. This project discusses various &lt;strong&gt;important&lt;/strong&gt; array prototype methods that I found super helpful. Do check it out if you haven't already&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be Ajax Type Ahead .&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Project 4: Array Cardio Day 1</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Sat, 04 Dec 2021 20:39:13 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-4-array-cardio-day-1-3b1k</link>
      <guid>https://dev.to/prachigarg19/project-4-array-cardio-day-1-3b1k</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 4 and project 4. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 4 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This challenge was more theoretical rather than implementation. It explained various array prototype methods that I found super helpful and so I'll be explaining each method taught in this challenge and I strongly recommend you to not skip this challenge.&lt;/p&gt;

&lt;p&gt;I'll be linking the documentations I referred for each function to further clear up the topic.&lt;br&gt;
&lt;strong&gt;Before proceeding you should be familiar with arrow functions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.filter()&lt;/strong&gt;: It is used to filter elements of array that returns true for any condition written inside the function passed as it's parameter. It returns an array of such elements.&lt;/p&gt;

&lt;p&gt;E.g. Suppose we have an array=[1,2,3,4,5,6] and we want to get odd elements from this array. There are 2 ways to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let result=[];
for(item of array)
{
 if(item%2!=0) result.push(item);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now this can be done in a single line using filter() method.&lt;br&gt;
It takes a function as a parameter(which will contain our condition), and the parameter function further takes the current element being checked, index(optional) and array on which filter is used(optional) as parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let result=array.filter( (item)=&amp;gt;item%2!=0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here item is the current element, and if item%2 returns true only then the value would be added to result.&lt;/p&gt;

&lt;p&gt;See how code has been reduced to single line.&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter"&gt;Here&lt;/a&gt; is the documentation I read along with the video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.map():&lt;/strong&gt;  It is used when we want to traverse an array and change values of all it's elements. It creates a new array with modified elements and hence, is not preferred if the new array isn't useful/ if we are not using the returned array further in our code.&lt;/p&gt;

&lt;p&gt;e.g. we want to add 1 to each element of array:&lt;br&gt;
First way is to traverse an array using for loop and then add 1 to each element.&lt;br&gt;
Second way-&amp;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 array=[1,2,3,4,5];    

result=array.map( (item)=&amp;gt;item+=1);

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

&lt;/div&gt;



&lt;p&gt;Map takes three arguments: the value of the element, the index of the element(optional), and the array object being mapped(optional) just like filter().&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"&gt;Here&lt;/a&gt; is the documentation I read along with the video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.reduce():&lt;/strong&gt; It is used when we want to add calculation of previous elements to the next element. &lt;br&gt;
It takes two parameters, the function that will perform calculations and an initial value(optional).&lt;br&gt;
If initial value is not provided, then the array will be traversed from the second element ,taking first element as the previous value and second as the current value. If specified, initial value is given to the previous element and traversing begins from the first element of array.&lt;/p&gt;

&lt;p&gt;function passed as parameters takes 4 upto values:&lt;br&gt;
 previousValue: the value resulting from the previous call to function. On first call, initialValue if specified, otherwise the value of array[0].&lt;br&gt;
currentValue: the value of the current element. On first call, the value of array[0] if an initialValue was specified, otherwise the value of array[1].&lt;br&gt;
currentIndex: the index position of currentValue in the array. On first call, 0 if initialValue was specified, otherwise 1.(optional)&lt;br&gt;
array: the array to traverse (optional)&lt;/p&gt;

&lt;p&gt;e.g. suppose we want the products of elements in our array&lt;br&gt;
First way-&amp;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 array=[1,2,3,4,5];    
let result=1;
for(item of array)
{
    result*=item;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second way (using reduce)-&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;result=array.reduce(((product,next)=&amp;gt;product*=next),1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here first argument is the value that is finally returned by reduce function and second value is the current element value. I've provided the initial value 1 that will be given to product during 1st iteration.I can skip giving initial value as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce"&gt;Here&lt;/a&gt; is the documentation I read along with the video.&lt;/p&gt;

&lt;p&gt;Note: these methods will give console error if not used with array.If you want to use it on non array collection then use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from"&gt;Array.from(collection)&lt;/a&gt; which converts an array instance from an array-like or iterable object. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;strong&gt;Things I learnt:&lt;/strong&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;1.map()&lt;br&gt;
2.reduce()&lt;br&gt;
3.filter()&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;u&gt;Previous article from this series:&lt;/u&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-3css-variables-n04"&gt;Project 3 Day 3&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;u&gt;Conclusion&lt;/u&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be Flex panel Image gallery  .&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Project 3:CSS Variables</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Sat, 04 Dec 2021 08:25:36 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-3css-variables-n04</link>
      <guid>https://dev.to/prachigarg19/project-3css-variables-n04</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 3 and project 3. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 3 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the final result:&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;CODE&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/prachigarg19/embed/yLzYoLW?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;PART 1:HTML&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;In html part as you can see I've created 3 inputs. The thing to notice here is that I've given name to the input similar to variable names as we will later use them to manipulate variable values. I've created data-sizing variable which will store px. Keep reading to understand why it's needed. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;PART 2:CSS&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Now we are going to style our project.&lt;br&gt;
Here we have created 3 variables in root. As I said, notice variable names are similar to name of inputs.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;em&gt;PART 3:JAVASCRIPT&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Now we will make our project interactive.&lt;br&gt;
The idea is to get all input tags from document, traverse them and call function updateValues when input is clicked or when mouse is moved upon range input to change values. Without mousemove event Listener the function will not take values until range input is stopped at a point. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;updateValue function-&amp;gt;&lt;/u&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 suffix=this.dataset.sizing||"";
    document.documentElement.style.setProperty(`--${this.name}`,this.value+suffix);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;suffix will store the dataset sizing value that is px. This is required as we want to set variable values to somethingpx.&lt;br&gt;
Example- If user sets padding value to 18 then we need to update&lt;br&gt;
 --padding variable to 18px. Thus we need to concatenate 18 and string px to achieve this. &lt;br&gt;
Also since image does not have a data-sizing set to it we have set an or condition in suffix initialisation to prevent concatenation of undefined.This can also be achieved by setting data-sizing="" in img but this is not a good method for larger code bases as we'd then need to add data-sizing="" to all the inputs.&lt;/p&gt;

&lt;p&gt;Now we will update css value by calling setProperty function of style .of document element ,which is further a part of document ,for name of the input that called the function (same as variable name) to the value of this input(returns value set by user/initial value set by programmer). (Tip: this is a complicated part hence try breaking it and printing on console to get the idea or you can comment below and I'll be happy to help you)&lt;br&gt;
For more details on this part ,read &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;u&gt;Previous article from this series:&lt;/u&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-2javascript-clock-5a0c"&gt;Day 2 Project 2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the working code :&lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30"&gt;github&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Things learnt:&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;1.mousemove event listener.&lt;br&gt;
2.css variables.&lt;br&gt;
3.updating variables from javascript&lt;br&gt;
4.dataset&lt;br&gt;
5.filter property in css (here used to blur image)&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;u&gt;Conclusion&lt;/u&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be Array Cardio Day 1.&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>Project 2:JavaScript Clock</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Fri, 03 Dec 2021 10:08:51 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-2javascript-clock-5a0c</link>
      <guid>https://dev.to/prachigarg19/project-2javascript-clock-5a0c</guid>
      <description>&lt;p&gt;Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 2 and project 2. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 2 challenge of &lt;a href="https://javascript30.com/"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the final result:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--auOZRTdX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8l86vcfsj0o3v2bac4i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--auOZRTdX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8l86vcfsj0o3v2bac4i.png" alt="JS clock" width="880" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always before starting download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30/tree/master/02%20-%20JS%20and%20CSS%20Clock"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;em&gt;PART 1:HTML&lt;/em&gt;
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Clock&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
    &amp;lt;div class="hand hour-hand" id="hour"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div class="hand min-hand" id="min" &amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div class="hand sec-hand" id="sec"&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;PART 2:CSS&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Now we are going to style our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*{
    margin:0;
    padding:0;
}
body{
    background-color: rgb(33, 33, 36);
    display: flex;
    justify-content: center;
}
.container{
    border:20px solid white;
    border-radius: 50%;
    position: absolute;
    margin-top: 8rem;
    height:25vw;
    width: 25vw;
    transition: ease-in-out;

}
.hand{
    position: relative;
    top: 50%;
    width:47%;
    left:3%;
    height: 0.6rem;
    background-color: white;
    transform: rotate(90deg);
    transform-origin: 100%;

}
.hour-hand,.sec-hand,.min-hand {
   position: absolute;
}



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

&lt;/div&gt;



&lt;p&gt;Let's look at the styling part for hand class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hand{
    position: relative;
    top: 50%;
    width:47%;
    left:3%;
    height: 0.6rem;
    background-color: white;
    transform: rotate(90deg);
    transform-origin: 100%;

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

&lt;/div&gt;



&lt;p&gt;Position has been set to relative so that hands can be positioned with respect to container that is the clock boundary. Then we can easily set top and width accordingly to center the hands.&lt;br&gt;
Hand class will be a common class to all hour,min and sec hand. We have used transform(90deg) to start all the hands from 12o'clock (as div content is horizontal by default).&lt;/p&gt;

&lt;p&gt;Here transform:origin has been used as on applying transform, rotate hands will be rotated from center(by default) , hence we set origin to 100% to rotate it from the end.&lt;/p&gt;

&lt;p&gt;One issue that we will face is that our 3 hands will appear in block format as div is a block property by default.To solve this we will use position:absolute at individual hand classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hour-hand,.sec-hand,.min-hand {
   position: absolute;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer to &lt;a href="https://stackoverflow.com/questions/1909648/stacking-divs-on-top-of-each-other"&gt;this&lt;/a&gt; for more details on stacking divs part.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;PART 3:JAVASCRIPT&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Now we will make our project interactive.&lt;/p&gt;

&lt;p&gt;Here the idea is to change transform:rotate property for each hand class as per change in hours,min and sec and calling each function again and again every sec using setInterval() function.&lt;/p&gt;

&lt;p&gt;Let's look at the function for hour hand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function changeHour(){
    let hour=document.getElementById('hour');
    let hangle;
    if(date.getHours()&amp;lt;12)
    {   
        hangle=(date.getHours()*30);
    }
    else hangle=(date.getHours()-12)*30+90;
    hour.style.transform=`rotate(${hangle}deg)`;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we will take two cases. If our hour is less than 12 then we will simply multiply it by 30 deg as hour hand moves 30deg after every hour and we will add it to 90deg as initially our hand is at 90deg. If our hour is&amp;gt;=12 then we will subtract them by 12.&lt;br&gt;
Here's an example- If hour returned by getHours() is 1 (1am) then our hour-hand will be at 1*(360/12) degrees.&lt;br&gt;
If 13 is returned( 1pm) then (13-12)*(360/12) will give 30 degrees.&lt;/p&gt;

&lt;p&gt;Same logic goes for min and sec -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function changeMin(){
    date=new Date();
    let min=document.getElementById('min');
    let mangle=date.getMinutes()*6+90;  
    min.style.transform=`rotate(${mangle}deg)`;
}
function changeSec(){
    date=new Date();
    let sec=document.getElementById('sec');
    let sangle=date.getSeconds()*6;
    sangle+=90;   
    sec.style.transform=`rotate(${sangle}deg)`;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have to call these function every second-&lt;br&gt;
Here we will use setInterval(function,time interval in milisecond),which will keep on calling function passed as parameter after time interval passed as second parameter until closeInterval() is closed,which we won't call since we want our function to keep on running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setInterval(changeSec,1000);
setInterval(changeMin,1000);
setInterval(changeHour,1000);

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;em&gt;&lt;u&gt;Previous article from this series:&lt;/u&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/project-1-javascript-drumkit-3b06"&gt;Project 1 Day 1&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Things learnt:&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;1.Stacking divs&lt;br&gt;
2.transform-origin&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Source Code&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30"&gt;Feel free to suggest changes&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;u&gt;Conclusion&lt;/u&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be on CSS variables.&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Project 1: JavaScript DrumKit</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Thu, 02 Dec 2021 10:28:58 +0000</pubDate>
      <link>https://dev.to/prachigarg19/project-1-javascript-drumkit-3b06</link>
      <guid>https://dev.to/prachigarg19/project-1-javascript-drumkit-3b06</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;br&gt;
Welcome to my "Build 30 Js Projects in 30 Days" Series .This is day 1 and project 1. If you haven't read the other articles in this series please check them out first. I'll list them at the end of this article.&lt;/p&gt;

&lt;p&gt;As mentioned in my previous article. This is the Day 1 challenge of &lt;a href="https://javascript30.com/" rel="noopener noreferrer"&gt;Wes Bos Javascript30 course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the final result:&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%2Fz7skeaa3szatlzejg9ok.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%2Fz7skeaa3szatlzejg9ok.png" alt="JavaScript drumkit image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always before starting, download the starter files from &lt;a href="https://github.com/wesbos/JavaScript30/tree/master/01%20-%20JavaScript%20Drum%20Kit" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I've made a separate article on how to download starter files, you can check it out &lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;PART 1:HTML&lt;/strong&gt;
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
         &amp;lt;div class="bg-wrap"&amp;gt;
             &amp;lt;img class="bg-image" src="background.jpg"&amp;gt;
         &amp;lt;/div&amp;gt;
        &amp;lt;table&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="65"&amp;gt;A &amp;lt;span&amp;gt;Clap&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="83"&amp;gt;S &amp;lt;span&amp;gt;Hihat&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="68"&amp;gt;D &amp;lt;span&amp;gt;Kick&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="70"&amp;gt;F &amp;lt;span&amp;gt;OpenHat&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="71"&amp;gt;G &amp;lt;span&amp;gt;Boom&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="72"&amp;gt;H &amp;lt;span&amp;gt;Ride&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="74"&amp;gt;J &amp;lt;span&amp;gt;Snare&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="75"&amp;gt;K &amp;lt;span&amp;gt;Tom&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td class="drum-key"&amp;gt;&amp;lt;button value="76"&amp;gt;L &amp;lt;span&amp;gt;Tink&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
        &amp;lt;/table&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;

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

&lt;/div&gt;


&lt;p&gt;The thing to notice here is that I've given value of buttons as ascii value of characters mentioned on drum keys. I've created a table with 1 row and each data cell is a button.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;PART 2:CSS&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now we are going to style our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*{
    margin: 0;
    padding:0;

}
body{
    overflow: hidden;
}
.container{
    position: relative;
}
.bg-image{
    background: url('background.jpg') center;
    opacity: 0.7;
    position: absolute;
    top:0;
    bottom:0;
    width:100%;
    height:auto;
    z-index:-1;
    position: relative;
}
table{
    margin-left: auto;
    margin-right: auto;
    position: absolute;
    top: 55%;
    z-index:2;

}
table td button{
    width:3.5em;
    height:3em;
    font-size:2rem;
    color: white;
    background: transparent;
    border:2px solid black;
    transition: all 0.06s;
    margin:1rem;

}
table td button span{
    font-size: 1rem;
    color:gold;
   display: block;

}
.bright{
    border: 2px solid gold;
    box-shadow: 0px 3px gold;
    transform: scale(1.2);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here bright class will be called when a sound is being played.Now as this article focuses mostly on javascript, I'm not getting deep into css explanation part. Try to read through it and if you've any suggestions or doubts, feel free to comment below.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;PART 3:JAVASCRIPT&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now we will make our project interactive.&lt;br&gt;
So the idea of this project is to play sound when &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;u&gt;Key mentioned on the button is pressed on keyboard&lt;/u&gt;:
Here we will use event listener keydown. We will use keyCode to get the key pressed by user. Then we will pass it to a function to play the corresponding sound.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;We click the button using cursor.&lt;/u&gt;
Here we will get the value of button clicked by using event listener click and then we will pass it to the function to play the sound.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Initialising audio variables  --&amp;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 clap= new Audio('sounds/clap.wav');
let boom= new Audio('sounds/boom.wav');
let hihat= new Audio('sounds/hihat.wav');
let kick= new Audio('sounds/kick.wav');
let openhat= new Audio('sounds/openhat.wav');
let ride= new Audio('sounds/ride.wav');
let snare= new Audio('sounds/snare.wav');
let tink= new Audio('sounds/tink.wav');
let tom= new Audio('sounds/tom.wav');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will solve the cases as explained above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let keys=document.getElementsByClassName('drum-key');

for(let key of keys){
   //This will play sound when any key is pressed
    key.addEventListener('keydown',(e)=&amp;gt;{


             //******adding bright class*****

        //will call button having keycode as value.
         let keyboardvalue=document.querySelector(`button[value="${e.keyCode}"]`);

         //if any non displayed key is pressed.
         if(keyboardvalue)
        keyboardvalue.classList.add('bright');
        playSound(e.keyCode);

        //since transitioning is already a time bound property, using another time bound function is not recommended.
            //    setTimeout(()=&amp;gt;
            //     {keyboardvalue.classList.remove('bright');
            //     },500);


    })
                //*******to remove bright class*******
    // we will use property transitionend.
        key.addEventListener('transitionend',(e1)=&amp;gt;{
        //since transitionend triggers every time transition is made i.e. for change in borders etc. as well , we are returning if transitionend is not triggered for property transform.

        if(e1.propertyName!='transform') return;
        e1.target.classList.remove('bright');
       })

            //******when button is clicked****
    key.addEventListener('click',(e2)=&amp;gt;{
        console.log(e2.target.value);
        if(e2.target.value)
        {playSound(parseInt(e2.target.value));
         //Value data type is string so we will convert it to integer as switch case takes integer as parameter.
        e2.target.classList.add('bright');}
    })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will create function playSound which takes the ascii value of key as parameter and plays the corresponding sound using swich-case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function playSound(ch){
    switch(ch)
        { 
            case 65: {clap.currentTime=0; 
//if one audio is playing then same audio will not play again as function is already running. to prevet this we et currenttime=0.          
                     clap.play();}
                     break;
            case 83: hihat.currentTime=0;
                      hihat.play();
                     break;
            case 68: kick.currentTime=0;
                      kick.play();
                    break;
            case 70: openhat.currentTime=0;
                      openhat.play();
                    break;
            case 71: boom.currentTime=0;
                      boom.play();
                    break;
            case 72: ride.currentTime=0;
                      ride.play();
                    break;
            case 74: snare.currentTime=0;
                      snare.play();
                    break;
            case 75: tom.currentTime=0;
                      tom.play();
                    break;
            case 76: tink.currentTime=0;
                      tink.play();
                    break;
        }
}

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

&lt;/div&gt;



&lt;p&gt;I hope you understood the whole code. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;Source code:&lt;/u&gt; &lt;a href="https://github.com/prachigarg19/Javacript_beginner_projects/tree/main/js30/drum" rel="noopener noreferrer"&gt;Click here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Things I learnt&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;1.keydown event listener.&lt;br&gt;
2.transitionend event listener.&lt;br&gt;
3.transform and transition.&lt;br&gt;
4.Alternative to using setTimeout function with transition.&lt;br&gt;
5.How to play audio again even if play() function is already running for that audio. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Previous article from this series:&lt;/u&gt;&lt;/strong&gt;:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j"&gt;Click here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Conclusion&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;That's it for today's project.Next project will be an Alarm Clock .&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you.&lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Build 30 JavaScript projects in 30 days:Day 0</title>
      <dc:creator>prachigarg19</dc:creator>
      <pubDate>Wed, 01 Dec 2021 19:09:51 +0000</pubDate>
      <link>https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j</link>
      <guid>https://dev.to/prachigarg19/build-30-javascript-projects-in-30-daysday-0-2m8j</guid>
      <description>&lt;p&gt;This is building 30 projects in 30 days series. I'll be following Wes Bos Javascript30 course for this challenge,the link to which is: &lt;a href="https://javascript30.com/"&gt;https://javascript30.com/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'll be sharing my approach in every article which may or may not be same as the one mentioned in his videos.&lt;/p&gt;

&lt;p&gt;Before starting with this series I'd recommend you to download the starter files in your device, the link to which is &lt;a href="https://github.com/wesbos/JavaScript30"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Process to download starter files -&amp;gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fork&lt;/strong&gt; the repo by clicking the option in the top right.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clone repo:&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.a. If you have &lt;u&gt;github desktop&lt;/u&gt; installed (which I recommend as it is easier to work with), click on the green colored 'code' option and then click open with gitub desktop. Now the application will automatically clone the repo to your device. After cloning they'll be two options on your screen-&amp;gt; contribute to parent project ( choose this if you want to make contribution to the repo, which in this case, you're not) . Second, for your own use. Choose this one.&lt;/p&gt;

&lt;p&gt;2.b. &lt;u&gt;Using git bash:&lt;/u&gt; Refer to this &lt;a href="https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository"&gt;article&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now go to the folder where repo has been cloned and congrats there is your starter package! You can copy and paste all the sounds,images etc. to your project folder as per your requirements and use them in your projects.&lt;/p&gt;

&lt;p&gt;This is it for today. In my next article, I will discuss the first project, which is a DrumKit.&lt;/p&gt;

&lt;p&gt;If you have any doubts or suggestions please do let me know in the comment section. I'll be more than happy to interact with you. &lt;/p&gt;

&lt;p&gt;If you like this series and want to be a part of it, do consider following me at &lt;a class="mentioned-user" href="https://dev.to/prachigarg19"&gt;@prachigarg19&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Thanks for reading. :)&lt;/p&gt;

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