<?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: Nirbhay Parmar</title>
    <description>The latest articles on Forem by Nirbhay Parmar (@nirbhayparmar).</description>
    <link>https://forem.com/nirbhayparmar</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%2F503506%2F9dbdd8e0-4b96-46bf-845a-1f67110c59dc.jpg</url>
      <title>Forem: Nirbhay Parmar</title>
      <link>https://forem.com/nirbhayparmar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nirbhayparmar"/>
    <language>en</language>
    <item>
      <title>#JavaScript-30 day -10</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Sat, 19 Mar 2022 09:00:13 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/javascript-30-day-10-33mg</link>
      <guid>https://forem.com/nirbhayparmar/javascript-30-day-10-33mg</guid>
      <description>&lt;p&gt;Hey fellow learners, how are you going? &lt;/p&gt;

&lt;p&gt;Today, I am sharing my experiments with the projects from &lt;a href="https://javascript30.com/" rel="noopener noreferrer"&gt;#JavaScript30&lt;/a&gt; series by Wes Bos.&lt;/p&gt;

&lt;p&gt;For today's post, I have chosen the project of day-10 which is on creating a small component in which we can checked multiple checkbox at one click. So lets dive into the code and try to understand the how I approached the problem and (how I am wrong about my approach😂.) &lt;/p&gt;

&lt;p&gt;At first the HTML and CSS files are given in the course. We just have to add our logic via JavaScript. But before discussing the solution, first understand what is the problem statement? So, the problem statement is like there are multiple checkbox, after clicking any one checkbox as soon as we click some other checkbox, all the checkbox between the first clicked and second clicked are also checked together with the second checkbox.&lt;br&gt;
&lt;a href="https://media2.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%2Fc71ggllm54ndhtdzko64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fc71ggllm54ndhtdzko64.png" alt="model" width="800" height="792"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, now discuss, how I approached this problem. First I thought that if somehow we can keep track of index of first and second clicked object than we can checked the checkbox that lie between them. So I created two variables named &lt;code&gt;firstChecked&lt;/code&gt; and &lt;code&gt;lastChecked&lt;/code&gt; and added two event listener on all the checkbox of the same click event type. And in the first event listener I tried to update the &lt;code&gt;firstChecked&lt;/code&gt; variable with the index of first checked checkbox and in the second event listener the same process for the &lt;code&gt;lastChecked&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And then I thought that now I just have to select the indexes between that two checkbox and make it checked. But here is the catch, As I have added two different event listeners on the same object having same type of event behave as a single event, obviously but at that time I did not realised it. So started console logging the values of &lt;code&gt;firstChecked&lt;/code&gt; and &lt;code&gt;lastChecked&lt;/code&gt; after clicking two different checkbox but it will showing same index. It will show same index as per the code but for me who at that time not understand that logic is frustrating. &lt;/p&gt;

&lt;p&gt;I went on debugging it. After some 1 or 2 hours, I realized my mistake and decided to watch the solution given by Wes itself. And got it right. Here is the solution of that problem. (You can download the problem files from this &lt;a href="https://github.com/wesbos/JavaScript30" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;checkboxArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input[type=checkbox]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;checkboxArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleCheck&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleCheck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shiftKey&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// console.log(lastIndex, "inside if");&lt;/span&gt;
        &lt;span class="nx"&gt;checkboxArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//to check weather the checkbox we are at is working is checked or not.&lt;/span&gt;
                &lt;span class="nx"&gt;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;lastIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastIndex&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// in the below approach(what I thought) the main fault is that &lt;/span&gt;
&lt;span class="c1"&gt;//the two separate event lister of the same event type will always &lt;/span&gt;
&lt;span class="c1"&gt;//take action at simulteneously. so i cannot get the separate &lt;/span&gt;
&lt;span class="c1"&gt;//value of the last checked checkbox after checking next checkbox.&lt;/span&gt;

&lt;span class="c1"&gt;// let firstIndex = null,&lt;/span&gt;
&lt;span class="c1"&gt;//  secondIndex = null;&lt;/span&gt;
&lt;span class="c1"&gt;// console.log(checkboxArray);&lt;/span&gt;
&lt;span class="c1"&gt;// checkboxArray.forEach((box) =&amp;gt; {&lt;/span&gt;
&lt;span class="c1"&gt;//  box.addEventListener("click", firstBox);&lt;/span&gt;
&lt;span class="c1"&gt;// });&lt;/span&gt;
&lt;span class="c1"&gt;// checkboxArray.forEach((box) =&amp;gt; {&lt;/span&gt;
&lt;span class="c1"&gt;//  box.addEventListener("click", secondBox);&lt;/span&gt;
&lt;span class="c1"&gt;// });&lt;/span&gt;
&lt;span class="c1"&gt;// function firstBox(e) {&lt;/span&gt;
&lt;span class="c1"&gt;//  firstIndex = checkboxArray.indexOf(this);&lt;/span&gt;
&lt;span class="c1"&gt;//  console.log(firstIndex);&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;span class="c1"&gt;// function secondBox(e) {&lt;/span&gt;
&lt;span class="c1"&gt;//  if (e.shiftKey) {&lt;/span&gt;
&lt;span class="c1"&gt;//      secondIndex = checkboxArray.indexOf(this);&lt;/span&gt;
&lt;span class="c1"&gt;//  }&lt;/span&gt;

&lt;span class="c1"&gt;//  console.log(secondIndex);&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;


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

&lt;/div&gt;



&lt;p&gt;You can view the working model &lt;a href="https://nirbhayparmar.github.io/js30/" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;br&gt;
So the moral of the story is, please understand the basics of the methods or functions you are using in your code in order avoid this type of fundamental mistakes.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Curious Case of Junior Developer</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Tue, 11 Jan 2022 14:31:31 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/a-curious-case-of-junior-developer-3hpd</link>
      <guid>https://forem.com/nirbhayparmar/a-curious-case-of-junior-developer-3hpd</guid>
      <description>&lt;p&gt;Hey readers, let us see this scenario, many of us had faced this scenario in our learning phase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start
&lt;/h2&gt;

&lt;p&gt;You may heard many advice saying that you must have your portfolio website to showcase your work yourself to the world and to build a personal brand. And after hearing that advice you starts to gear up your thoughts and decided to make a cool and professional looking portfolio website.&lt;/p&gt;

&lt;p&gt;So, after you have decided that you need a portfolio website, you starts to search YouTube for best developer portfolio website examples or something related to it and binge watching it till 2:00 am in midnight and stops when you see your data pack is over.&lt;/p&gt;

&lt;p&gt;After it you sets on a particular design for your portfolio and as soon as you starting to code, you came across a tutorial for designing the website using Figma or Adobe XD. Now you watched that video and follow it to create a design for your website. Your design looks very cool and professional. Now you sit and started coding to make your design a reality.&lt;/p&gt;

&lt;p&gt;After two-three hours of coding the HTML and CSS for your website you think that why i am not getting the design that i have created in Figma. You restlessly try and debug the code to make it work. After some time you say &lt;strong&gt;yes i have started creating my website and &lt;em&gt;it sucks&lt;/em&gt;, now i need some rest so, i &lt;em&gt;solve the bugs next day&lt;/em&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But that &lt;strong&gt;&lt;em&gt;next day&lt;/em&gt;&lt;/strong&gt; never comes in a while. During some random thoughts you reconcile your memory about your unfinished portfolio and you again started coding. But instead of fixing the bugs in older project, you created a new file and started coding from scratch. And again you stuck in the same cycle of trying to fix the bugs and left it unfinished and restart it again.&lt;/p&gt;

&lt;p&gt;So, you think why am i doing all this? Was i be able to do it or not? And then you decided to do it again. But this time you are able to complete your portfolio website in just two month and host it.&lt;/p&gt;

&lt;h2&gt;
  
  
  End
&lt;/h2&gt;

&lt;p&gt;Now you readers think that why am I telling this sad story to you all but the thing is all the above mention events are happened with &lt;strong&gt;me.&lt;/strong&gt; Yes, I binge watched like 10 to 12 YouTube video for find &lt;strong&gt;&lt;em&gt;inspiration.&lt;/em&gt;&lt;/strong&gt; And i found myself in so called '&lt;em&gt;tutorial hell&lt;/em&gt;'. In general this happens with majority of beginners. They fell in tutorial hell and think that they need to be perfect or need to know it all to make a portfolio or in general became a developer.&lt;/p&gt;

&lt;p&gt;So if don't want to fell in tutorial hell then start your favorite code editor (mine is VS Code) and start coding your portfolio website.&lt;/p&gt;

&lt;p&gt;In my next post I will share my journey of what i did different last time to finally complete my portfolio website and how i got myself out from tutorial hell.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So, until then keep coding....&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Credits for &lt;a href="https://unsplash.com/photos/weRQAu9TA-A?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditShareLink" rel="noopener noreferrer"&gt;cover photo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Type Conversions in JavaScript</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Wed, 01 Dec 2021 14:39:45 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/type-conversions-in-javascript-3b1c</link>
      <guid>https://forem.com/nirbhayparmar/type-conversions-in-javascript-3b1c</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the previous post of this series, I have explained about all the &lt;a href="https://dev.to/nirbhayparmar/all-data-types-in-javascript-237a"&gt;data types&lt;/a&gt; that are present in JavaScript. If you did not read it then you may read it first to understand all the data types in detail or if you have knowledge about the data types then you may continue reading this post.&lt;/p&gt;

&lt;p&gt;In this post, I am explaining about the type conversions in JavaScript. As we know that JavaScript is &lt;em&gt;dynamically typed&lt;/em&gt; language, we don't need to specify the data type while creating any variables. Sometimes we requires that the some value stored in a variable as some other data type then it was already like the variable is storing a number data type and we require that value as a string. The concept of &lt;em&gt;type conversion&lt;/em&gt; comes into picture here.&lt;/p&gt;

&lt;p&gt;Type conversion achieved in JavaScript in two ways-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Automatic Type Conversion&lt;/li&gt;
&lt;li&gt;Explicit Type Conversion&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now lets talk them about in detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automatic Type Conversion
&lt;/h2&gt;

&lt;p&gt;As the name suggests it is automatically done by JavaScript itself. Some functions like &lt;code&gt;alert()&lt;/code&gt; will convert any given type to string to display it.&lt;/p&gt;

&lt;p&gt;Another example of it is that when we apply the non-numbers to mathematical expressions or functions then the non-numbers are automatically converted to numbers. For example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;subtract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are some more ways in which automatic type conversion is happen but I want to try on your own in your browser's console in dev tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explicit Type Conversion
&lt;/h2&gt;

&lt;p&gt;Explicit type conversion means that we have explicitly have to convert the data type of the value stored in a variable, by using some functions.&lt;/p&gt;

&lt;p&gt;In JavaScript, we have generally four type of explicit type conversions such as-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;string conversion&lt;/li&gt;
&lt;li&gt;numeric conversion&lt;/li&gt;
&lt;li&gt;boolean conversion&lt;/li&gt;
&lt;li&gt;object to primitive conversion&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post, I am just covering first three only because object to primitive conversion needed knowledge deeper understanding of objects, that I may cover in my future post.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. String Conversion
&lt;/h3&gt;

&lt;p&gt;To convert the other values to string data type, we have used &lt;code&gt;string(other value)&lt;/code&gt; function. It is most obvious type of conversion because the value stays as it is but its data type is now changed to string.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//number to string&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// numValue is of number data type.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;convertedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;convertedValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// string&lt;/span&gt;

&lt;span class="c1"&gt;//boolean to string&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;boolValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// boolValue is of boolean data type.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stringValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boolValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;stringValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Numeric Conversion
&lt;/h3&gt;

&lt;p&gt;Numeric conversion is slightly complicated but i will explain it via examples that takes the complexity away. So numeric conversion is possible by a function called &lt;code&gt;Number(otherValue)&lt;/code&gt;.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stringValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;123&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// string data type&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;booleanValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//boolean data type&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numValue1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stringValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numValue2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;booleanValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numValue3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;booleanValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// for false boolean value&lt;/span&gt;

&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;numValue1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number as numValue1 is 123&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;numValue2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number as numValue2 is 1&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;numValue3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number as numValue3 is 0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update- 11/12/2021&lt;/p&gt;

&lt;p&gt;I am going through JavaScript.info to revise &lt;a href="https://javascript.info/operators#numeric-conversion-unary" rel="noopener noreferrer"&gt;operators&lt;/a&gt; in JavaScript, then I show the use of unary &lt;code&gt;+&lt;/code&gt; operator. It can also used to convert other data types to number. If we put &lt;code&gt;+&lt;/code&gt; operator before any variable containing non-number data types then it will convert it to numeric form and use its numerical value.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "56"&lt;/span&gt;
&lt;span class="c1"&gt;// but when we use + operator before the varible then&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 11&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Boolean Conversion
&lt;/h3&gt;

&lt;p&gt;Boolean conversion is easy because it has only one rule that is when any empty string &lt;code&gt;""&lt;/code&gt; or &lt;code&gt;0&lt;/code&gt; is converted to boolean using &lt;code&gt;Boolean()&lt;/code&gt; function then it is false othervise it is true.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stringValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;boolValue1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stringValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;boolValue2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boolValue1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boolValue2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stringValue1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numValue1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;boolValue3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stringValue1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;boolValue4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numValue1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boolValue3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boolValue4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  some points to remember
&lt;/h2&gt;

&lt;p&gt;Some people often confused when it comes to converting &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;"0"&lt;/code&gt; to boolean because both of then seems to equal but, &lt;code&gt;0&lt;/code&gt; is converted to false in boolean and &lt;code&gt;"0"&lt;/code&gt; is converted to true because &lt;code&gt;"0"&lt;/code&gt; is string having 0 as a character while &lt;code&gt;0&lt;/code&gt; is a number.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="c1"&gt;// try this code in console window of dev tools of your browser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other common mistake is that they convert &lt;code&gt;undefined&lt;/code&gt; and &lt;code&gt;null&lt;/code&gt; to number, &lt;code&gt;undefined&lt;/code&gt; is converted to &lt;code&gt;NaN&lt;/code&gt; and &lt;code&gt;null&lt;/code&gt; is converted to &lt;code&gt;0&lt;/code&gt;.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="c1"&gt;// try this code in console window of dev tools of your browser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we are converting string to number then if the string have some trailing or leading white spaces then it will discarded. If the string contains some non-numeric characters then it will converted to &lt;code&gt;NaN&lt;/code&gt;. The empty string becomes &lt;code&gt;0&lt;/code&gt;.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  123  &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;123@#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// try this code in console window of dev tools of your browser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In boolean conversion, the &lt;code&gt;NaN&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt; and &lt;code&gt;null&lt;/code&gt; are also converted to &lt;code&gt;false&lt;/code&gt;. The space-only string &lt;code&gt;" "&lt;/code&gt; is true.&lt;br&gt;
Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//NaN&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;// space only string&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value4&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// try this code in console window of dev tools of your browser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;I know this post is looking some what complicated when you first look at it, but if read this post and try the code given here in your browser console then the things became clear.&lt;br&gt;
Thank you for reading this post.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post is based on what I learned about data types in JavaScript from &lt;a href="https://javascript.info/type-conversions" rel="noopener noreferrer"&gt;javascript.info.&lt;/a&gt; It is basically a summary of that article. Visit it to get some deeper understanding.&lt;/em&gt;&lt;br&gt;
Photo by &lt;a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Pankaj Patel&lt;/a&gt; on &lt;a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>All Data Types in JavaScript</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Tue, 09 Nov 2021 19:40:09 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/all-data-types-in-javascript-237a</link>
      <guid>https://forem.com/nirbhayparmar/all-data-types-in-javascript-237a</guid>
      <description>&lt;p&gt;If you are a beginner in web development then you must learn the JavaScript. It powers the interactions on each and every webpages. Basically it enables the websites to interact with the user in many ways like music player, alert, pop-ups or a video player or animations.&lt;/p&gt;

&lt;p&gt;But to create such interactions on the websites developers need to write the code that take user inputs or call an &lt;a href="https://www.howtogeek.com/343877/what-is-an-api/" rel="noopener noreferrer"&gt;api&lt;/a&gt; to get any data, but to do all this things we need some type of storage container that will store different types of data like numbers, strings, objects or boolean. So each programming languages defines some data types to sort the things out.&lt;/p&gt;

&lt;p&gt;The JavaScript is a &lt;em&gt;"dynamically typed"&lt;/em&gt; language, we not have to specify the data types at variable declaration unlike C/C++ or Java. Variables can store any data type in it. There are total 8 data types in JavaScript. These are as follows-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;BigInt&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Null&lt;/li&gt;
&lt;li&gt;Undefined&lt;/li&gt;
&lt;li&gt;Object&lt;/li&gt;
&lt;li&gt;Symbol&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Number
&lt;/h2&gt;

&lt;p&gt;Numbers as the name suggest, it used to store numbers. Numbers can be integers, fractions, or Infinity/-Infinity and NaN(Not a Number).&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// integer&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;fraction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt; &lt;span class="c1"&gt;// fraction&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;infinity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;Infinity&lt;/span&gt; &lt;span class="c1"&gt;// Infinity&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;notANumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="c1"&gt;// NaN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  String
&lt;/h2&gt;

&lt;p&gt;String is the type of data in which, there is a bunch of alphanumeric characters and other symbols are together. In other words, it is a group of characters. Strings are to be surrounded by quotes, single or double. &lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;abc123,./&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="c1"&gt;// string can have alphanumeric and other symbols&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;`The back-tics can used to use variables in in between the string like str is- &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// The back-tics can used to use variables in in between the string like str is- abc123,./ &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  BigInt
&lt;/h2&gt;

&lt;p&gt;BigInt is made to accommodate really large numbers which are more than 2^53 -1 or less -(2^53 -1) due to its technical limitations. They are represented by appending 'n' after the number.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bigint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123456789123456789123456789&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Boolean
&lt;/h2&gt;

&lt;p&gt;Boolean is used to represent true or false values. Sometimes we only two values for our function or we have to check some condition that is true or false.&lt;br&gt;
Boolean values can also come as a result of comparision. &lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isTrueOrFalse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstIsGreaterOrNot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstIsGreaterOrNot&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Null
&lt;/h2&gt;

&lt;p&gt;People often confused between null value and undefined value(non existing value). Null values represents "nothing", "empty" or "unknown".&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// null&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Undefined
&lt;/h2&gt;

&lt;p&gt;They are different then Null data types. They represents that the variable is not assigned any value.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Object
&lt;/h2&gt;

&lt;p&gt;Objects are non primitive data type. We can defined key-value pairs. We can store any type values in one such object. We can store collections of data of different data types.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Nirbhay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="na"&gt;isIndian&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Symbol
&lt;/h2&gt;

&lt;p&gt;Symbol are used to create unique identifiers for objects. They can used to generate unique identifiers.&lt;/p&gt;

&lt;p&gt;No example for this because i have to read more on it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post is based on what I learned about data types in JavaScript from &lt;a href="https://javascript.info/types" rel="noopener noreferrer"&gt;javascript.info.&lt;/a&gt; It is basically a summary of that article. Visit it to get some deeper understanding.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;cover photo by &lt;a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Pankaj Patel&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/code?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Basic Git commands for beginners</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Wed, 28 Jul 2021 15:50:55 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/basic-git-commands-for-beginners-2bcb</link>
      <guid>https://forem.com/nirbhayparmar/basic-git-commands-for-beginners-2bcb</guid>
      <description>&lt;p&gt;Hello everyone!!&lt;/p&gt;

&lt;p&gt;I am Nirbhay Parmar and I am a learning web developer. In this post I will be explaining some basic Git terminologies which is useful if you are entering into development field or want to contribute in any open source project on Github.&lt;/p&gt;

&lt;p&gt;Now the first question arises from this introduction is that what is Git and why should I even care about it? Some of the beginners are also confused between Git and Github. So let me explain the Git first then I will explain about Github after it. &lt;/p&gt;

&lt;p&gt;Git is a version controlling software. It is used by developers for maintaining different versions of any project they are working on. In an ongoing development process there are many developers working on a single project. They are working with one or two features of that project. So they need a system that can keep track of the changes and commits made on a project and if someone broke the code while experimenting on any feature then there should a way to reverse that faulty code. So Git does the same. Git keep track on files and code used in a project and give a way to make different versions of same projects called "branches" to experiment without worrying about breaking the code. &lt;/p&gt;

&lt;p&gt;Now what is Github? Github is a place to store your code or your repository online to share it with your team or online. All open source projects are on Github and any who knows how to code can contribute to it. Another such service are Bitbucket and Gitlab.&lt;/p&gt;

&lt;p&gt;Now some basic Git commands- &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git init -&lt;/strong&gt; Git init is used to initiate a local git repository. It is first command whenever we want to use git.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git status -&lt;/strong&gt; It shows the status of the working tree. Git status is used to show the changes made, any newly created file that is not added to repo.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git add -&lt;/strong&gt; As the name suggests it used add new files and folders to git.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git commit -&lt;/strong&gt; It is used to save changes to the repository. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git clone -&lt;/strong&gt; It is used to setup a local git repo using any other remote git repo hosted on Github or Bitbucket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git push -&lt;/strong&gt; It is used to push commits to your remote repo.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git pull -&lt;/strong&gt; It is used to fetch changes made by others to remote repo to your local repo.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So these are some common Git commands which we can use in your projects. &lt;/p&gt;

&lt;p&gt;There are so many other commands which I will discuss in upcoming parts of this series.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My 30 days of Js journey: day 5</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Mon, 11 Jan 2021 19:57:50 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/my-30-days-of-js-journey-day-5-5b40</link>
      <guid>https://forem.com/nirbhayparmar/my-30-days-of-js-journey-day-5-5b40</guid>
      <description>&lt;h1&gt;
  
  
  day 5
&lt;/h1&gt;

&lt;p&gt;Today I learnt how to set &lt;code&gt;style.backgroundImage&lt;/code&gt; property to dynamically change the background image of the div tag. &lt;/p&gt;

&lt;p&gt;At first, I thought that it is a fair easy and straight forward task, but as it goes on I have to change my perception about the problem. I have to append the URL of an image to the empty URL property of the &lt;code&gt;background-image&lt;/code&gt; CSS property.&lt;/p&gt;

&lt;p&gt;Here is the HTML code of that div that i want to change the background-image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"image"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hover over an image below to display here.&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;
      &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"preview"&lt;/span&gt;
      &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Styling with a Bandana"&lt;/span&gt;
      &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon.jpg"&lt;/span&gt;
      &lt;span class="na"&gt;onmouseover=&lt;/span&gt;&lt;span class="s"&gt;"upDate(this)"&lt;/span&gt;
      &lt;span class="na"&gt;onmouseout=&lt;/span&gt;&lt;span class="s"&gt;"unDo()"&lt;/span&gt;
    &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is my CSS code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#image {
  width: 575px;
  height: 650px;
  border: 5px solid black;
  margin: 0 auto;
  background-color: #8e68ff;
  background-image: url("");
  background-repeat: no-repeat;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here is the javascript function to do the same:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;upDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;previewPic&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;Url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;previewPic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;image&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;url(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;Url&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;image&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;previewPic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In HTML there is a div which has a text in it. While it has some &lt;code&gt;background-color&lt;/code&gt;. In my function, I want to change the &lt;code&gt;background-color&lt;/code&gt; to a &lt;code&gt;background-image&lt;/code&gt; with an image URL. So I have to concatenate the image URL.&lt;/p&gt;

&lt;p&gt;This was done as a part of my Coursera course on web design. &lt;/p&gt;

</description>
      <category>learning</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Starting a new challenge: #30daysofJs</title>
      <dc:creator>Nirbhay Parmar</dc:creator>
      <pubDate>Thu, 07 Jan 2021 06:51:50 +0000</pubDate>
      <link>https://forem.com/nirbhayparmar/starting-a-new-challenge-30daysofjs-1jl1</link>
      <guid>https://forem.com/nirbhayparmar/starting-a-new-challenge-30daysofjs-1jl1</guid>
      <description>&lt;h1&gt;
  
  
  Why this challenge?
&lt;/h1&gt;

&lt;p&gt;I started this challenge to get rid of my fear for &lt;strong&gt;JavaScript.&lt;/strong&gt; I usually only watch tutorials and read &lt;em&gt;dev.to&lt;/em&gt; posts. I just became the content consumer of those posts and YouTube tutorials. I watched loads of videos on JavaScript and feels that i knew JavaScript but in reality, when it comes to coding for practice, started forgetting the syntax and started questioning my self that if i am able to do this or not and after some time again fall into &lt;strong&gt;&lt;em&gt;tutorial hell&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution to this problem
&lt;/h2&gt;

&lt;p&gt;To get rid of so called "tutorial hell", I decided to start this challenge. This help me to become more accountable towards my goals because i have to post about my progress everyday on twitter and on here. This forces me to write some actual code and learn the syntax that I am always forgetting.&lt;/p&gt;


&lt;blockquote&gt;
&lt;p&gt;From today onwards i am starting to post my daily progress on my &lt;a href="https://twitter.com/hashtag/30daysofJsChallange?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#30daysofJsChallange&lt;/a&gt; &lt;a href="https://t.co/WsTHL3DgzY" rel="noopener noreferrer"&gt;pic.twitter.com/WsTHL3DgzY&lt;/a&gt;&lt;/p&gt;— Nirbhay Parmar (@NirbhayNP14) &lt;a href="https://twitter.com/NirbhayNP14/status/1347063110381670402?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;January 7, 2021&lt;/a&gt;
&lt;/blockquote&gt; 

&lt;p&gt;Please follow me here and on twitter to help me accountable and to cheer me up.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
