<?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: Majida Majida</title>
    <description>The latest articles on DEV Community by Majida Majida (@majida_majida_f9c32da3f6b).</description>
    <link>https://dev.to/majida_majida_f9c32da3f6b</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4236746%2Fd68a957a-4b6d-4dbd-a1a5-150def1ac077.jpg</url>
      <title>DEV Community: Majida Majida</title>
      <link>https://dev.to/majida_majida_f9c32da3f6b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/majida_majida_f9c32da3f6b"/>
    <language>en</language>
    <item>
      <title>Building a Topsoil Calculator: Area x Depth = Cubic Yards</title>
      <dc:creator>Majida Majida</dc:creator>
      <pubDate>Tue, 10 Nov 2026 09:44:14 +0000</pubDate>
      <link>https://dev.to/majida_majida_f9c32da3f6b/building-a-topsoil-calculator-area-x-depth-cubic-yards-4ep9</link>
      <guid>https://dev.to/majida_majida_f9c32da3f6b/building-a-topsoil-calculator-area-x-depth-cubic-yards-4ep9</guid>
      <description>&lt;p&gt;A topsoil calculator is one of the shortest tools you can build, and that is the point. The whole job is one multiplication, then a division. The mistakes people make with it are measurement mistakes, not maths mistakes, so the code should stay simple and the page should spend its words on measuring.&lt;/p&gt;

&lt;p&gt;The formula is volume in cubic feet first, then cubic yards. Length in feet times width in feet times depth in feet gives cubic feet. Depth is usually measured in inches, so divide it by 12 first. A cubic yard holds 27 cubic feet, so divide the cubic feet by 27. Put together, cubic yards equals length times width times depth in inches, divided by 324.&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;cubicYards&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lengthFt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;widthFt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;depthIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lengthFt&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;widthFt&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;depthIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;324&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;Run a raised bed through it. Four feet wide, eight feet long, six inches deep. Four times eight times six is 192. Divide by 324 and you get about 0.59 cubic yards. Order one cubic yard and you have enough for the bed and a little left for topping up after the first rain. A bigger bed, ten feet by twelve feet at four inches deep, comes out at about 1.48 cubic yards. The numbers stay small enough to check by hand, which is worth doing the first time you test the tool.&lt;/p&gt;

&lt;p&gt;Round beds need one extra step before the formula. Measure straight across the middle for the diameter, halve it for the radius, and work out the area as 3.14 times the radius squared. Then multiply by the depth in feet and divide by 27. In code that is:&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;roundBedYards&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diameterFt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;depthIn&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="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;diameterFt&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;depthIn&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;27&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;For a bed with a curve or a corner cut out, split it into rectangles and run each part through the calculator on its own, then add the cubic yards together at the end. Adding the lengths together first gives the wrong answer when the depths differ, and they usually do. Depth is the number people measure least and get wrong most. Push a ruler into the bed in five or six places, take the average, and use that. If the readings run from 4 inches to 8 inches, the average is 6, and that is the number to use.&lt;/p&gt;

&lt;p&gt;Two small touches make the tool feel finished. First, round the answer up to one decimal place and show the cubic feet beside it, so a user can see the working. Second, suggest ordering about a tenth more than the sum. Soil settles, beds are uneven, and a second small delivery costs more than the extra soil would have. That suggestion is not part of the maths, it is part of using the answer, and it belongs on the page.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://topsoilcalconline.com/" rel="noopener noreferrer"&gt;topsoil calculator&lt;/a&gt; runs the same formula with the measuring steps written out beside it, which is a good check for your own version. If your numbers match it on the 4 by 8 bed above, your code is right. If they do not, check the 324 first. It is the one number in the whole tool that is easy to mistype, and it is where most wrong answers come from.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building a Gauge-to-MM Converter: The Math Behind the Tool</title>
      <dc:creator>Majida Majida</dc:creator>
      <pubDate>Tue, 10 Nov 2026 09:43:58 +0000</pubDate>
      <link>https://dev.to/majida_majida_f9c32da3f6b/building-a-gauge-to-mm-converter-the-math-behind-the-tool-nll</link>
      <guid>https://dev.to/majida_majida_f9c32da3f6b/building-a-gauge-to-mm-converter-the-math-behind-the-tool-nll</guid>
      <description>&lt;p&gt;A gauge number on its own is not a thickness. It is a row in a table, and there are several tables. That is why a gauge converter is not one formula. It is a small lookup tool with one real formula inside it, for wire, and tables for everything else.&lt;/p&gt;

&lt;p&gt;Wire is the part with a formula. American Wire Gauge follows a fixed rule. The diameter in millimetres is 0.127 times 92 raised to the power of (36 minus AWG) divided by 39. Put 12 in for AWG and you get about 2.05 mm. Put 14 in and you get about 1.63 mm. Put 16 in and you get about 1.29 mm. Put 18 in and you get about 1.02 mm. Each step up in AWG cuts the diameter by a fixed ratio, close to 0.89, so the sizes shrink in even steps even though the numbers look uneven.&lt;/p&gt;

&lt;p&gt;In JavaScript that is one line once you have the input:&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;awgToMm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;awg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.127&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;92&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;awg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;39&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Round the result to two decimal places for display. More digits look precise but the wire itself is made to a tolerance, so the extra digits mean nothing on a real coil. A check with calipers on a 12 AWG copper wire should read near 2.05 mm. If it reads far off that, the wire is probably labelled to a different standard, or the label is wrong.&lt;/p&gt;

&lt;p&gt;Sheet metal has no formula like that. The Manufacturers Standard Gauge is a table that mills agreed on, not a curve you can calculate. In mild steel, 16 gauge is about 1.5 mm, 18 gauge is about 1.2 mm, and 20 gauge is about 0.9 mm. The metal matters as well. Sixteen gauge copper is 1.651 mm while 16 gauge brass is 1.291 mm, so a converter needs a table per metal, not one table for all sheet. The &lt;a href="https://gaugetomillimeters.com/sheet-metal-gauge-chart-guide/" rel="noopener noreferrer"&gt;sheet metal gauge chart guide&lt;/a&gt; lists the common metals side by side, which is the table to copy from when you build the lookup.&lt;/p&gt;

&lt;p&gt;A plain object holds that table well enough for a small tool:&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="n"&gt;sheetMm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;mildSteel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;copper&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.651&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;brass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.291&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Needles are a third table again. A medical needle marked 18 gauge has an outside diameter of about 1.27 mm. A 21 gauge needle is about 0.82 mm across, and a 22 gauge needle is about 0.72 mm. Those sizes are fixed by an international standard, so a lookup table is the right shape here too. There is no formula to derive them from.&lt;/p&gt;

&lt;p&gt;The structure that falls out of this is simple. Ask the user for the system first: sheet, wire, or needle. Then ask for the metal where it changes the answer. Then look the number up, or run the AWG formula if the system is wire. If the gauge is not in the table, say so plainly instead of guessing a nearby row. A converter that admits it does not know a size is more useful than one that invents one.&lt;/p&gt;

&lt;p&gt;One more detail that trips people up in code: the numbers run backwards in all three systems. A higher gauge number means a thinner piece. If your UI sorts the table by gauge number, the millimetres will run the other way, and that looks like a bug to a first time user even though it is correct. A short note next to the result saves that confusion. The full &lt;a href="https://gaugetomillimeters.com/" rel="noopener noreferrer"&gt;tables on gaugetomillimeters.com&lt;/a&gt; show sheet, wire, and needle sizes in one place, which is handy when you are checking your own lookup values against a second source.&lt;/p&gt;

</description>
      <category>coding</category>
      <category>javascript</category>
      <category>programming</category>
      <category>software</category>
    </item>
  </channel>
</rss>
