<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[JavaScript in Plain English - Medium]]></title>
        <description><![CDATA[New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers. - Medium]]></description>
        <link>https://javascript.plainenglish.io?source=rss----4b3a1ed4f11c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>JavaScript in Plain English - Medium</title>
            <link>https://javascript.plainenglish.io?source=rss----4b3a1ed4f11c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 11 Oct 2026 09:29:38 GMT</lastBuildDate>
        <atom:link href="https://javascript.plainenglish.io/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[TypeScript 7.0 Ships 10x Faster — But These 8 Breaking Changes Bite First]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/typescript-7-0-ships-10x-faster-but-these-8-breaking-changes-bite-first-51983c404541?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/2400/1*R_c6IlIj_X-BCiyplN7x8g.png" width="2400"></a></p><p class="medium-feed-snippet">The real risk isn&#x2019;t compiler speed &#x2014; it&#x2019;s rootDir, types, and six more silent breaks.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/typescript-7-0-ships-10x-faster-but-these-8-breaking-changes-bite-first-51983c404541?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/typescript-7-0-ships-10x-faster-but-these-8-breaking-changes-bite-first-51983c404541?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/51983c404541</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ray Hu]]></dc:creator>
            <pubDate>Sun, 11 Oct 2026 07:33:21 GMT</pubDate>
            <atom:updated>2026-10-11T07:33:19.943Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[10 npm Package Warning Signs JavaScript Developers Should Never Ignore]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/10-npm-package-warning-signs-javascript-developers-should-never-ignore-5819057ff917?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/1536/1*-TLPg8LQj6Wg0DNPLgVFZg.png" width="1536"></a></p><p class="medium-feed-snippet">A package can look legitimate and still introduce serious risks.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/10-npm-package-warning-signs-javascript-developers-should-never-ignore-5819057ff917?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/10-npm-package-warning-signs-javascript-developers-should-never-ignore-5819057ff917?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/5819057ff917</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Huzair Awan]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 21:24:56 GMT</pubDate>
            <atom:updated>2026-10-10T21:24:55.331Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Every Bug Became Easier to Fix When I Learned These 7 Layers of Software]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/every-bug-became-easier-to-fix-when-i-learned-these-7-layers-of-software-b679079e1278?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/1376/1*LZkbtjRYVaBTmnk68k3LyA.png" width="1376"></a></p><p class="medium-feed-snippet">When most developers run into a production bug, their immediate instinct is to start changing code. They add log statements, adjust&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/every-bug-became-easier-to-fix-when-i-learned-these-7-layers-of-software-b679079e1278?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/every-bug-became-easier-to-fix-when-i-learned-these-7-layers-of-software-b679079e1278?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/b679079e1278</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Webstack]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 16:19:54 GMT</pubDate>
            <atom:updated>2026-10-10T16:19:53.261Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The Temporal Dead Zone Explained With Real JavaScript Errors]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/the-temporal-dead-zone-explained-with-real-javascript-errors-4fec6d1caf7e?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/1376/1*H21Vz23RfgTobSJOp4xEwQ.png" width="1376"></a></p><p class="medium-feed-snippet">Have you ever run a piece of JavaScript code, only to see ReferenceError: Cannot access &apos;x&apos; before initialization flash across your&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/the-temporal-dead-zone-explained-with-real-javascript-errors-4fec6d1caf7e?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/the-temporal-dead-zone-explained-with-real-javascript-errors-4fec6d1caf7e?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/4fec6d1caf7e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Webstack]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 16:19:43 GMT</pubDate>
            <atom:updated>2026-10-10T16:19:42.427Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[JavaScript for Python Developers: 12 Things That Will Trip You Up]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/javascript-for-python-developers-12-things-that-will-trip-you-up-50957f2c6767?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/2600/0*uqRtosO_apFRebWl" width="5184"></a></p><p class="medium-feed-snippet">Most of them fail without raising an error, which is exactly why they hurt.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/javascript-for-python-developers-12-things-that-will-trip-you-up-50957f2c6767?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/javascript-for-python-developers-12-things-that-will-trip-you-up-50957f2c6767?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/50957f2c6767</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[__mar_mmah]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 16:19:25 GMT</pubDate>
            <atom:updated>2026-10-10T16:19:23.743Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[7 Angular 22 Mistakes Even Experienced Developers Still Make]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/7-angular-22-mistakes-even-experienced-developers-still-make-cd3b0a18b624?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/2600/0*t4ZtIBhGmum7GhsX" width="5472"></a></p><p class="medium-feed-snippet">Signals, Signal Forms, httpResource, RxJS, and the subtle architectural decisions that can break a modern Angular application in&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/7-angular-22-mistakes-even-experienced-developers-still-make-cd3b0a18b624?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/7-angular-22-mistakes-even-experienced-developers-still-make-cd3b0a18b624?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/cd3b0a18b624</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular-22]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Bestte]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 09:52:28 GMT</pubDate>
            <atom:updated>2026-10-10T09:52:27.237Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[A Tree and a Wand: How JavaScript Changes a Webpage]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/a-tree-and-a-wand-how-javascript-changes-a-webpage-d50ba3a6b0e3?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/1280/1*rn0UEgQvnwokNUCpVE-FNQ.png" width="1280"></a></p><p class="medium-feed-snippet">The mental model</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/a-tree-and-a-wand-how-javascript-changes-a-webpage-d50ba3a6b0e3?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/a-tree-and-a-wand-how-javascript-changes-a-webpage-d50ba3a6b0e3?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/d50ba3a6b0e3</guid>
            <category><![CDATA[dom]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Clemence Ayekple]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 09:52:14 GMT</pubDate>
            <atom:updated>2026-10-10T09:52:13.460Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[JavaScript Doesn’t Run Your Code Line by Line the Way You Think]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/javascript-doesnt-run-your-code-line-by-line-the-way-you-think-2a145e9331eb?source=rss----4b3a1ed4f11c---4"><img src="https://cdn-images-1.medium.com/max/1536/1*UzCh5Xag3sX5EDozzHQmvQ.png" width="1536"></a></p><p class="medium-feed-snippet">JavaScript runs one statement at a time. That doesn&#x2019;t mean it runs them in the order you wrote them.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/javascript-doesnt-run-your-code-line-by-line-the-way-you-think-2a145e9331eb?source=rss----4b3a1ed4f11c---4">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/javascript-doesnt-run-your-code-line-by-line-the-way-you-think-2a145e9331eb?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/2a145e9331eb</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[tamimbuilds]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 09:42:01 GMT</pubDate>
            <atom:updated>2026-10-10T09:41:59.989Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[JavaScript Program to Count Even and Odd Numbers in an Array]]></title>
            <link>https://javascript.plainenglish.io/javascript-program-to-count-even-and-odd-numbers-in-an-array-eb18b7d79a36?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/eb18b7d79a36</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 06:56:57 GMT</pubDate>
            <atom:updated>2026-10-10T06:56:56.045Z</atom:updated>
            <content:encoded><![CDATA[<p>In JavaScript, arrays are used to store multiple values in a single variable. When working with numerical data, we often need to identify and count how many numbers are even and how many are odd.</p><p>An even number is a number that is exactly divisible by 2, while an odd number leaves a remainder of 1 or -1 when divided by 2.</p><p>For example, consider the following array:</p><blockquote>const numbers = [10, 15, 20, 25, 30, 35, 40];</blockquote><p>In this array, the even numbers are 10, 20, 30, 40 and the odd numbers are 15, 25, 35.</p><p>Therefore, the total count is:</p><ul><li>Even numbers: 4</li><li>Odd numbers: 3</li></ul><p>In this article, we will learn how to count even &amp; odd numbers in a JavaScript array using different methods.</p><h3><strong>1. JavaScript Program to Count Even and Odd Numbers Using a For Loop</strong></h3><p>The for loop is one of the simplest methods for counting even and odd numbers in an array. We use the modulo operator (%) to determine whether each number is divisible by 2.</p><h4><strong>Program :</strong></h4><pre>const numbers = [10, 15, 20, 25, 30, 35, 40];<br>let evenCount = 0;<br>let oddCount = 0;<br>for (let i = 0; i &lt; numbers.length; i++) {<br>if (numbers[i] % 2 === 0) {<br>evenCount++;<br>} else {<br>oddCount++;<br>}<br>}<br>console.log(&quot;Even numbers count:&quot;, evenCount);<br>console.log(&quot;Odd numbers count:&quot;, oddCount);</pre><h4><strong>Output :</strong></h4><p>Even numbers count: 4</p><p>Odd numbers count: 3</p><h4><strong>Explanation :</strong></h4><ol><li>We create an array named numbers containing seven integers.</li><li>We initialize evenCount and oddCount to 0.</li><li>The for loop visits every element in the array.</li><li>The condition numbers[i] % 2 === 0 checks whether the current number is even.</li><li>If the condition is true, evenCount increases by one. Otherwise, oddCount increases by one.</li><li>Finally, we display both counts using console.log().</li></ol><p>This approach is easy to understand and is suitable for beginners learning JavaScript loops and conditional statements.</p><h3><strong>2. JavaScript Program to Count Even and Odd Numbers Using a For…of Loop</strong></h3><p>The for…of loop provides a simple way to iterate over array values without using an index.</p><h4><strong>Program :</strong></h4><pre>const numbers = [2, 7, 12, 19, 24, 31, 36];<br>let evenCount = 0;<br>let oddCount = 0;<br>for (const number of numbers) {<br>if (number % 2 === 0) {<br>evenCount++;<br>} else {<br>oddCount++;<br>}<br>}<br>console.log(&quot;Even numbers count:&quot;, evenCount);<br>console.log(&quot;Odd numbers count:&quot;, oddCount);</pre><h4><strong>Output :</strong></h4><p>Even numbers count: 4</p><p>Odd numbers count: 3</p><h4><strong>Explanation :</strong></h4><p>The for…of loop assigns each array value to the variable number. The modulo operator checks whether that value is even or odd.</p><p>This method avoids manually managing an index and makes the program more readable.</p><h3><strong>3. JavaScript Program to Count Even and Odd Numbers Using forEach()</strong></h3><p>The forEach() method executes a callback function for every element in an array. We can use it to check each number and update the appropriate counter.</p><h4><strong>Program :</strong></h4><pre>const numbers = [11, 14, 17, 20, 23, 26, 29, 32];<br>let evenCount = 0;<br>let oddCount = 0;<br>numbers.forEach(function (number) {<br>if (number % 2 === 0) {<br>evenCount++;<br>} else {<br>oddCount++;<br>}<br>});<br>console.log(&quot;Even numbers count:&quot;, evenCount);<br>console.log(&quot;Odd numbers count:&quot;, oddCount);</pre><h4><strong>Output :</strong></h4><p>Even numbers count: 4</p><p>Odd numbers count: 4</p><h4><strong>Explanation :</strong></h4><p>The forEach() method passes each array element to the callback function. Inside the function, the modulo operator determines whether the number is even or odd.</p><p>The corresponding counter is incremented until every array element has been processed.</p><p>We can also use an arrow function, although the regular callback above is often easier for beginners to read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb18b7d79a36" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/javascript-program-to-count-even-and-odd-numbers-in-an-array-eb18b7d79a36">JavaScript Program to Count Even and Odd Numbers in an Array</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Program to Convert Decimal to Binary]]></title>
            <link>https://javascript.plainenglish.io/javascript-program-to-convert-decimal-to-binary-e482e79b7c81?source=rss----4b3a1ed4f11c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e482e79b7c81</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 06:56:44 GMT</pubDate>
            <atom:updated>2026-10-10T06:56:42.938Z</atom:updated>
            <content:encoded><![CDATA[<p>In JavaScript, converting a decimal number to binary is a common programming that helps developers understand number systems, loops and mathematical operations.</p><p>The decimal number system uses base 10 and contains digits from 0 to 9. In contrast, the binary number system uses base 2 and contains only two digits: 0 and 1. Computers use binary representation to process and store data.</p><blockquote>For example, the decimal number 10 is represented as 1010 in binary.</blockquote><p>In this article, we will learn how to convert a decimal number to binary in JavaScript using different methods.</p><h3><strong>1. JavaScript Program to Convert Decimal to Binary Using a While Loop</strong></h3><p>The while loop is a simple way to convert a decimal integer to binary. The basic idea is to repeatedly divide the number by 2 and record the remainder.</p><h4><strong>Program :</strong></h4><pre>function decimalToBinary(decimal) {<br>if (!Number.isSafeInteger(decimal) || decimal &lt; 0) {<br>throw new Error(&quot;Please enter a non-negative integer.&quot;);<br>}<br>if (decimal === 0) {<br>return &quot;0&quot;;<br>}<br>let binary = &quot;&quot;;<br>while (decimal &gt; 0) {<br>let remainder = decimal % 2;<br>binary = remainder + binary;<br>decimal = Math.floor(decimal / 2);<br>}<br>return binary;<br>}<br>console.log(decimalToBinary(10));<br>console.log(decimalToBinary(25));<br>console.log(decimalToBinary(50));</pre><h4><strong>Output :</strong></h4><p>1010</p><p>11001</p><p>110010</p><h4><strong>Explanation :</strong></h4><ol><li>The decimalToBinary() function accepts a decimal integer.</li><li>It checks that the input is a non-negative integer.</li><li>If the input is 0, the function returns “0” immediately.</li><li>The while loop runs as long as the decimal number is greater than zero.</li><li>The modulo operator (%) calculates the remainder when the number is divided by 2.</li><li>The remainder is added to the beginning of the binary string.</li><li>Math.floor() divides the number by 2 and rounds the result down to an integer.</li><li>The loop stops when the number becomes zero and the function returns the binary representation.</li></ol><p>The remainder digits are generated from right to left, which is why each new remainder is added to the beginning of the string.</p><h3><strong>2. JavaScript Program to Convert Decimal to Binary Using the toString() Method</strong></h3><p>The JavaScript provides a built-in toString() method that can convert a number into a string representation.</p><h4><strong>Program :</strong></h4><pre>const decimal = 10;<br>const binary = decimal.toString(2);<br>console.log(&quot;Decimal number:&quot;, decimal);<br>console.log(&quot;Binary number:&quot;, binary);</pre><h4><strong>Output :</strong></h4><p>Decimal number: 10</p><p>Binary number: 1010</p><h4><strong>Explanation :</strong></h4><p>The toString(2) method converts the number into its base-2 representation.</p><h4>For example:</h4><p>console.log((5).toString(2)); // 101</p><p>console.log((12).toString(2)); // 1100</p><p>console.log((20).toString(2)); // 10100</p><p>console.log((100).toString(2)); // 1100100</p><h3><strong>3. JavaScript Program to Convert Decimal to Binary Using a For Loop</strong></h3><p>A for loop can also perform decimal-to-binary conversion. The loop repeatedly calculates the remainder and divides the number by 2.</p><h4><strong>Program :</strong></h4><pre>function decimalToBinary(decimal) {<br>if (!Number.isSafeInteger(decimal) || decimal &lt; 0) {<br>throw new Error(&quot;Please enter a non-negative safe integer.&quot;);<br>}<br>if (decimal === 0) {<br>return &quot;0&quot;;<br>}<br>let binary = &quot;&quot;;<br>for (; decimal &gt; 0; decimal = Math.floor(decimal / 2)) {<br>binary = (decimal % 2) + binary;<br>}<br>return binary;<br>}<br>console.log(&quot;Binary:&quot;, decimalToBinary(18));</pre><h4><strong>Output :</strong></h4><p>Binary: 10010</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e482e79b7c81" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/javascript-program-to-convert-decimal-to-binary-e482e79b7c81">JavaScript Program to Convert Decimal to Binary</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>