<?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: Amit Prajapati</title>
    <description>The latest articles on Forem by Amit Prajapati (@theamitprajapati).</description>
    <link>https://forem.com/theamitprajapati</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%2F889500%2Fc0bf25dc-87e7-468f-aef0-35f6d3051603.png</url>
      <title>Forem: Amit Prajapati</title>
      <link>https://forem.com/theamitprajapati</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/theamitprajapati"/>
    <language>en</language>
    <item>
      <title>this keyword in js</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Tue, 02 Apr 2024 09:27:54 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/this-keyword-in-js-2pfn</link>
      <guid>https://forem.com/theamitprajapati/this-keyword-in-js-2pfn</guid>
      <description>&lt;p&gt;&lt;code&gt;this&lt;/code&gt;keyword is very confusing many developers do not understand how this keyword works in deep!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>use of map method in javascript</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Wed, 06 Sep 2023 04:39:26 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/use-of-map-method-in-javascript-46k4</link>
      <guid>https://forem.com/theamitprajapati/use-of-map-method-in-javascript-46k4</guid>
      <description>&lt;p&gt;map method return new array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let clothPrices = [350, 200, 500, 800]
let discountPercent = 10 //percent 

let discountedClothPrices =  clothPrices.map((price)=&amp;gt;{
    let amount = (price * discountPercent)/100;
    return (price - amount).toFixed(2);
})  

console.log(discountedClothPrices)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Reading file in nodejs with use of module fs and path</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Sun, 29 Jan 2023 15:32:37 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/reading-file-in-nodejs-with-use-of-module-fs-and-path-1nm6</link>
      <guid>https://forem.com/theamitprajapati/reading-file-in-nodejs-with-use-of-module-fs-and-path-1nm6</guid>
      <description>&lt;p&gt;Hi!&lt;/p&gt;

&lt;h2&gt;
  
  
  By asynchronously
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const  fs = require("fs");
const path = require("path");

const fileUrl = path.join(__dirname, "test.txt");
fs.readFile(fileUrl,(err,data)=&amp;gt;{
    console.log("fileData: ",data)
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  By synchronously
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const  fs = require("fs");
const path = require("path");

const fileUrl = path.join(__dirname, "test.txt");
const fileData = fs.readFileSync(fileUrl);
console.log(fileData )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>What should be the output in javascript console ?</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Fri, 28 Oct 2022 11:41:30 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/what-should-be-the-output-in-javascript-console--2l07</link>
      <guid>https://forem.com/theamitprajapati/what-should-be-the-output-in-javascript-console--2l07</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; (1+2,2+6,5+5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I was trying to put in chrome console.log to print the 10. I have not understood .why only 10 editions were gone 1+2 and 2+6 ??.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Preview how CSS border-radius values affect an element</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Thu, 28 Jul 2022 15:45:27 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/preview-how-css-border-radius-values-affect-an-element-34ab</link>
      <guid>https://forem.com/theamitprajapati/preview-how-css-border-radius-values-affect-an-element-34ab</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const container = document.querySelector('#container').style;
const left = document.querySelector('#left');
const tops = document.querySelector('#top');
const right = document.querySelector('#right');
const buttom = document.querySelector('#buttom');
window.addEventListener('click',(e)=&amp;gt;{
  container.borderLeft = `2px solid red`; 
  container.borderTopLeftRadius = Number(left.value)+'px'; 
})
window.addEventListener('click',(e)=&amp;gt;{
  container.borderRight = `2px solid #e91e63`; 
  container.borderTopRightRadius = Number(tops.value)+'px'; 
})
window.addEventListener('click',(e)=&amp;gt;{
  container.borderTop = `2px solid #673ab7`; 
  container.borderBottomLeftRadius = Number(right.value)+'px'; 
})
window.addEventListener('click',(e)=&amp;gt;{
  container.borderBottom = `2px solid #009688`;

  container.borderBottomRightRadius = Number(buttom.value)+'px'; 
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1pfPKSDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yv525ddbhoa0n1bkpqcx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1pfPKSDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yv525ddbhoa0n1bkpqcx.png" alt="Image description" width="880" height="518"&gt;&lt;/a&gt;&lt;br&gt;
    *&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Write the program to convert the binary to decimal ?</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Fri, 15 Jul 2022 16:09:50 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/write-the-program-to-convert-the-binary-to-decimal--32bo</link>
      <guid>https://forem.com/theamitprajapati/write-the-program-to-convert-the-binary-to-decimal--32bo</guid>
      <description>&lt;p&gt;Binary is the number system all digital computers are based on. Therefore it's important for developers to understand binary, or base 2, mathematics. The purpose of Bin2Dec is to provide practice and understanding of how binary calculations&lt;br&gt;
app.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let decimal = document.getElementById('decimal');
let binary = document.getElementById('binary');
let error = document.getElementById('error');
let binaryNumber = '';
let maxInputLength = 10;
binary.addEventListener('keypress', (e) =&amp;gt; {
  error.innerHTML = '';
  if (binaryNumber.length == maxInputLength) {
    error.innerHTML = `You can enter only ${maxInputLength} the length of the binary`;
    return e.preventDefault();
  }
  if (!(e.key == 0 || e.key == 1)) {
    error.innerHTML = 'Invalid key press';
    binaryNumber.replace(e.key, '', '');
    binary.value = binaryNumber;
    e.preventDefault();
    return false;
  }
  binaryNumber += e.key
  decimal.innerHTML = binaryNumber;
})
let count = 0;
let decimalNumber = 0;
window.addEventListener('click', (e) =&amp;gt; {
  if (!binaryNumber.length) {
    return e.preventDefault();
  }
  for (let j = binaryNumber.length; j &amp;gt; 0; j--) {
    decimalNumber += Number(getDecimalNumber(j,Number(binaryNumber[count])))
    count++;
  }
  decimal.innerHTML = decimalNumber;
  decimalNumber = 0
})

function getDecimalNumber(count,binary) {
  let n = 0;
  switch (count) {
    case 1: n = binary ? 1 : 0; break;
    case 2: n = binary ? 2 : 0; break;
    case 3: n = binary ? 4 : 0; break;
    case 4: n = binary ? 8 : 0; break;
    case 5: n = binary ? 16 : 0; break;
    case 6: n = binary ? 32 : 0; break;
    case 7: n = binary ? 64 : 0; break;
    case 8: n = binary ? 128 : 0; break;
    case 9: n = binary ? 256 : 0; break;
    case 10: n = binary ? 512 : 0; break;
  }
  return n;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;index.html&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;body&amp;gt;
    &amp;lt;h2 style="text-align: center"&amp;gt;Binary to Decimal conversion&amp;lt;/h2&amp;gt;
    &amp;lt;div style="text-align: center"&amp;gt;
        &amp;lt;form&amp;gt;
            &amp;lt;div id="decimal"&amp;gt;0&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;
            &amp;lt;input type="text" id="binary" style="width:300px;padding:10px;font-size:16px;font-weight: 500;"&amp;gt;
            &amp;lt;div style="font-size:10px;color:red" id="error"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/form&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;script src="./app.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;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x6r2AR3S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g8tfu8zo996ptmcsoxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x6r2AR3S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g8tfu8zo996ptmcsoxg.png" alt="Image description" width="617" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note : It will work only one time for again reload the page&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>binary</category>
      <category>decimal</category>
    </item>
    <item>
      <title>Write the program to show the tringle ?</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Thu, 14 Jul 2022 16:21:43 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/write-the-program-to-show-the-tringle--56o1</link>
      <guid>https://forem.com/theamitprajapati/write-the-program-to-show-the-tringle--56o1</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let space = '';
let n = '';
let m = '';
for(let i=1;i&amp;lt;=6;i++){
    for(let j=6;j&amp;gt;=i;j--){
      space = space + ' - ';
    }
    for(let z=1;z&amp;lt;=i;z++){
        n = n + ` ${z} `
    }
    for(let k=i-1;k&amp;gt;=1;k--){
        m = m + ` ${k} `
    }
    console.log(space+n+m)
    n = '';
    space = '';
    m = '';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R4QDX7NB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/neeg7no93hvn7yizr9ng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R4QDX7NB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/neeg7no93hvn7yizr9ng.png" alt="Image description" width="357" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bigner</category>
      <category>star</category>
      <category>tringle</category>
    </item>
    <item>
      <title>Write a program to print prime numbers from 1 to 50</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Mon, 11 Jul 2022 16:19:55 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/write-a-program-to-print-prime-numbers-from-1-to-50-30k6</link>
      <guid>https://forem.com/theamitprajapati/write-a-program-to-print-prime-numbers-from-1-to-50-30k6</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(let i=2;i&amp;lt;=50;i++){  
    for(let j=2;j&amp;lt;=i;j++){
        let reminder = i%j;
        if(i != j){
         if(!reminder) break;
        }        
        if(j==i){
          console.log( i, ' is prime number')     
        }     
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Write the code to print the odd numbers ?</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Sun, 10 Jul 2022 14:09:37 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/write-the-code-to-print-the-odd-numbers--3a0l</link>
      <guid>https://forem.com/theamitprajapati/write-the-code-to-print-the-odd-numbers--3a0l</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(let i=1;i&amp;lt;=15;i++){
    if(i%2){
        console.log(i,'is the odd number`)
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Write the code to print the even numbers ?</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Sun, 10 Jul 2022 08:26:43 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/write-the-code-to-print-the-even-numbers--1h3d</link>
      <guid>https://forem.com/theamitprajapati/write-the-code-to-print-the-even-numbers--1h3d</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(let i=1;i&amp;lt;=50;i++){
    //Divided by 2 
    if(!(i%2)){
         console.log(i,'is the event number')
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>even</category>
      <category>number</category>
      <category>loop</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Hello World in Javascript !</title>
      <dc:creator>Amit Prajapati</dc:creator>
      <pubDate>Sat, 09 Jul 2022 15:16:01 +0000</pubDate>
      <link>https://forem.com/theamitprajapati/hello-world-in-javascript--459p</link>
      <guid>https://forem.com/theamitprajapati/hello-world-in-javascript--459p</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(" Hello world ! ")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>hello</category>
    </item>
  </channel>
</rss>
