<?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: CodeMonk</title>
    <description>The latest articles on DEV Community by CodeMonk (@monkcodes).</description>
    <link>https://dev.to/monkcodes</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%2F1094059%2Fb5804753-a8d6-4922-92e7-1cea8144c5ed.jpeg</url>
      <title>DEV Community: CodeMonk</title>
      <link>https://dev.to/monkcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/monkcodes"/>
    <language>en</language>
    <item>
      <title>API populate async await</title>
      <dc:creator>CodeMonk</dc:creator>
      <pubDate>Wed, 10 Apr 2024 11:24:48 +0000</pubDate>
      <link>https://dev.to/monkcodes/api-populate-async-await-40o0</link>
      <guid>https://dev.to/monkcodes/api-populate-async-await-40o0</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

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

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>CSS GRADIENT WAREHOUSE! Just one click away !!!</title>
      <dc:creator>CodeMonk</dc:creator>
      <pubDate>Sun, 17 Sep 2023 10:04:50 +0000</pubDate>
      <link>https://dev.to/monkcodes/css-gradient-warehousejust-one-click-away--he0</link>
      <guid>https://dev.to/monkcodes/css-gradient-warehousejust-one-click-away--he0</guid>
      <description>&lt;p&gt;Yes you heard it right !.Today while looking for css color palette, I somehow landed on this site. Very easy to use just click and you good to go. Tons of eye pleasing gradients are here. I have bookmarked it now.&lt;br&gt;
Share with your UI/UX or Frontend developers.&lt;br&gt;
Follow me for more!!!&lt;br&gt;
&lt;a href="https://cssgradient.io/gradient-backgrounds/"&gt;Link&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>ChatGPT helped me to convert my code from Xml API to Fetch API</title>
      <dc:creator>CodeMonk</dc:creator>
      <pubDate>Tue, 04 Jul 2023 04:28:21 +0000</pubDate>
      <link>https://dev.to/monkcodes/chatgpt-helped-me-to-convert-my-code-from-xml-api-to-fetch-api-46d6</link>
      <guid>https://dev.to/monkcodes/chatgpt-helped-me-to-convert-my-code-from-xml-api-to-fetch-api-46d6</guid>
      <description>&lt;p&gt;&lt;a href="https://codepen.io/Monk-Codes/full/yLQXxEG"&gt;&lt;/a&gt;## I USED AN OPEN API-REST COUNTRIES-&lt;br&gt;
MY PROMPT - could you convert my code from xml api to fetch api&lt;/p&gt;

&lt;p&gt;ChatGPT - Certainly! Please provide me with the code snippet you would like to convert from XML API to Fetch API, and I'll do my best to assist you with the conversion.&lt;/p&gt;

&lt;p&gt;My code-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict';

const btn = document.querySelector('.btn-country');
const countriesContainer = document.querySelector('.countries');

///////////////////////////////////////
const country = function (country) {
  const request = new XMLHttpRequest();
  request.open('GET', `https://restcountries.com/v3.1/name/${country}`);
  request.send();
  request.addEventListener('load', function () {
    const [data] = JSON.parse(this.responseText);
    console.log(data);
    let curr = data.currencies[Object.keys(data.currencies)[0]];
    const html = `
  &amp;lt;article class="country"&amp;gt;
  &amp;lt;img class="country__img" src="${data.flags.png}" /&amp;gt;
  &amp;lt;div class="country__data"&amp;gt;
          &amp;lt;h3 class="country__name"&amp;gt;${data.name.official}&amp;lt;/h3&amp;gt;
          &amp;lt;h4 class="country__region"&amp;gt;${data.subregion}&amp;lt;/h4&amp;gt;
          &amp;lt;p class="country__row"&amp;gt;&amp;lt;span&amp;gt;👫&amp;lt;/span&amp;gt;${(
            +data.population / 1000000
          ).toFixed(1)} people&amp;lt;/p&amp;gt;
          &amp;lt;p class="country__row"&amp;gt;&amp;lt;span&amp;gt;🗣️&amp;lt;/span&amp;gt;${data.languages.eng}&amp;lt;/p&amp;gt;
          &amp;lt;p class="country__row"&amp;gt;&amp;lt;span&amp;gt;💰&amp;lt;/span&amp;gt;${curr.name}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;/article&amp;gt;
        `;
    countriesContainer.insertAdjacentHTML('beforeend', html);
  });
};

country('usa');
country('canada');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict';

const btn = document.querySelector('.btn-country');
const countriesContainer = document.querySelector('.countries');

///////////////////////////////////////
const country = function (country) {
  fetch(`https://restcountries.com/v3.1/name/${country}`)
    .then(response =&amp;gt; response.json())
    .then(data =&amp;gt; {
      const [countryData] = data;
      console.log(countryData);
      let curr = countryData.currencies[Object.keys(countryData.currencies)[0]];
      const html = `
        &amp;lt;article class="country"&amp;gt;
          &amp;lt;img class="country__img" src="${countryData.flags.png}" /&amp;gt;
          &amp;lt;div class="country__data"&amp;gt;
            &amp;lt;h3 class="country__name"&amp;gt;${countryData.name.official}&amp;lt;/h3&amp;gt;
            &amp;lt;h4 class="country__region"&amp;gt;${countryData.subregion}&amp;lt;/h4&amp;gt;
            &amp;lt;p class="country__row"&amp;gt;&amp;lt;span&amp;gt;👫&amp;lt;/span&amp;gt;${(
              +countryData.population / 1000000
            ).toFixed(1)} people&amp;lt;/p&amp;gt;
            &amp;lt;p class="country__row"&amp;gt;&amp;lt;span&amp;gt;🗣️&amp;lt;/span&amp;gt;${countryData.languages.eng}&amp;lt;/p&amp;gt;
            &amp;lt;p class="country__row"&amp;gt;&amp;lt;span&amp;gt;💰&amp;lt;/span&amp;gt;${curr.name}&amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/article&amp;gt;
      `;
      countriesContainer.insertAdjacentHTML('beforeend', html);
    });
};

country('usa');
country('canada');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>Here is how ChatGPT helped me to fix my piece of code.</title>
      <dc:creator>CodeMonk</dc:creator>
      <pubDate>Tue, 20 Jun 2023 04:48:25 +0000</pubDate>
      <link>https://dev.to/monkcodes/here-is-how-chatgpt-helped-me-to-fix-my-piece-of-code-31lk</link>
      <guid>https://dev.to/monkcodes/here-is-how-chatgpt-helped-me-to-fix-my-piece-of-code-31lk</guid>
      <description>&lt;p&gt;hey correct my javascript code which i need in es6 version&lt;/p&gt;

&lt;p&gt;Of course! I'll be happy to help you convert your JavaScript code to the ES6 version. Please provide me with the code you'd like me to assist you with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict';

class Car {
  constructor(make, speed) {
    this.make = make;
    this.speed = speed;
  }

  accelerate() {
    this.speed += 10;
    console.log(`${this.make} is going at ${this.speed} km/h`);
  }
  brake() {
    this.speed -= 5;
    console.log(`${this.make} is going at ${this.speed} km/h`);
  }
  car1 = Car('BMW', 120);
  car2 = Car('Mercedes', 95);
}
accelerate();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sure! I have made some corrections to your code to align it with ES6 syntax. Here's the corrected code:&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;make&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;speed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&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;make&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;make&lt;/span&gt;&lt;span class="p"&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;speed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;speed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;accelerate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&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;speed&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&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="nx"&gt;log&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;make&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is going at &lt;/span&gt;&lt;span class="p"&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;speed&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; km/h`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;brake&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&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;speed&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;5&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="nx"&gt;log&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;make&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is going at &lt;/span&gt;&lt;span class="p"&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;speed&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; km/h`&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;car1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;BMW&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;car2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mercedes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;car1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accelerate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what has changed:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Removed the &lt;code&gt;car1&lt;/code&gt; and &lt;code&gt;car2&lt;/code&gt; assignments from within the class definition as they should be separate instances outside the class.&lt;/li&gt;
&lt;li&gt;Created &lt;code&gt;car1&lt;/code&gt; and &lt;code&gt;car2&lt;/code&gt; instances using the &lt;code&gt;new&lt;/code&gt; keyword and the &lt;code&gt;Car&lt;/code&gt; constructor.&lt;/li&gt;
&lt;li&gt;Called the &lt;code&gt;accelerate&lt;/code&gt; method on the &lt;code&gt;car1&lt;/code&gt; instance outside the class.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, you can run the code and it should work as expected. Let me know if you need any further assistance!&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Setting countdown timer in JS -oneliners</title>
      <dc:creator>CodeMonk</dc:creator>
      <pubDate>Sat, 03 Jun 2023 04:45:38 +0000</pubDate>
      <link>https://dev.to/monkcodes/setting-countdown-timer-in-js-oneliners-55pk</link>
      <guid>https://dev.to/monkcodes/setting-countdown-timer-in-js-oneliners-55pk</guid>
      <description>&lt;p&gt;const logoutTimer = function () {&lt;br&gt;
  let time = 120;&lt;br&gt;
//setting it to 2 min&lt;br&gt;
  const timer = setInterval(()=&amp;gt; {&lt;br&gt;
  const min = String(Math.trunc(time/60)).padStart(2, 0);&lt;br&gt;
    const sec = time % 60;&lt;br&gt;
    labelTimer.textContent = &lt;code&gt;${min}min:${sec}sec&lt;/code&gt;;&lt;br&gt;
//use your label where you want to place it&lt;br&gt;
    time--;&lt;br&gt;
    if (time === 0) {&lt;br&gt;
      clearInterval(timer);&lt;br&gt;
//this will end up your timer when it reaches 0sec&lt;br&gt;
//place your function here &lt;br&gt;
    }&lt;br&gt;
  }, 1000);&lt;br&gt;
};&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Best ES6 version of JavaScript of generating random colors using time interval</title>
      <dc:creator>CodeMonk</dc:creator>
      <pubDate>Fri, 02 Jun 2023 05:25:30 +0000</pubDate>
      <link>https://dev.to/monkcodes/best-es6-version-of-javascript-of-generating-random-colors-using-time-interval-18gl</link>
      <guid>https://dev.to/monkcodes/best-es6-version-of-javascript-of-generating-random-colors-using-time-interval-18gl</guid>
      <description>&lt;p&gt;const body = document.getElementsByTagName('BODY')[0];&lt;/p&gt;

&lt;p&gt;setInterval(function () {&lt;br&gt;
  const random = Math.floor(Math.random() * 16777215)&lt;br&gt;
    .toString(16)&lt;br&gt;
    .padStart(6, '0');&lt;br&gt;
  body.style.backgroundColor = '#' + random;&lt;br&gt;
}, 5500);&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>react</category>
    </item>
  </channel>
</rss>
