<?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[Stories by Aubrey Zulu on Medium]]></title>
        <description><![CDATA[Stories by Aubrey Zulu on Medium]]></description>
        <link>https://medium.com/@aubreyzulu?source=rss-6f16a71992fc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zzSfaJlGfuyb8vUtYqtFBA.jpeg</url>
            <title>Stories by Aubrey Zulu on Medium</title>
            <link>https://medium.com/@aubreyzulu?source=rss-6f16a71992fc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:45:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aubreyzulu/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[Essential JavaScript Functions: A Deep Dive with Use Cases]]></title>
            <link>https://medium.com/@aubreyzulu/essential-javascript-functions-a-deep-dive-with-use-cases-f203f01ffccc?source=rss-6f16a71992fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f203f01ffccc</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aubrey Zulu]]></dc:creator>
            <pubDate>Fri, 08 Dec 2023 17:44:22 GMT</pubDate>
            <atom:updated>2023-12-08T17:44:22.406Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript’s versatile array and string functions are vital tools for developers. Here, we explore some of these functions with detailed explanations and varied use cases ranging from basic to advanced.</p><h3>1. map()</h3><p><strong>Basic Use Case</strong>: Convert temperatures from Celsius to Fahrenheit.</p><pre>const celsius = [0, 10, 20, 30, 40];<br>const fahrenheit = celsius.map(temp =&gt; (temp * 9/5) + 32);<br>// Outputs: [32, 50, 68, 86, 104]</pre><p><strong>Advanced Use Case</strong>: Transform an array of objects, e.g., adding a new property to each object.</p><pre>const products = [{ name: &#39;Apple&#39;, price: 1 }, { name: &#39;Banana&#39;, price: 2 }];<br>const withTax = products.map(product =&gt; ({ ...product, priceWithTax: product.price * 1.2 }));<br>// Output: [{ name: &#39;Apple&#39;, price: 1, priceWithTax: 1.2 }, { name: &#39;Banana&#39;, price: 2, priceWithTax: 2.4 }]</pre><h3>2. find()</h3><p><strong>Basic Use Case</strong>: Find the first number greater than 10 in an array.</p><pre>const numbers = [3, 7, 11, 15, 20];<br>const firstLargeNumber = numbers.find(num =&gt; num &gt; 10);<br>// Output: 11</pre><p><strong>Advanced Use Case</strong>: Finding a specific object in an array of objects</p><pre>const users = [{ id: 1, name: &#39;Alice&#39; }, { id: 2, name: &#39;Bob&#39; }];<br>const user = users.find(user =&gt; user.id === 2);<br>// Output: { id: 2, name: &#39;Bob&#39; }<br></pre><h3>3. some()</h3><p><strong>Basic Use Case:</strong> Check if an array contains any even numbers.</p><pre>const array = [1, 3, 5, 7, 10];<br>const hasEven = array.some(num =&gt; num % 2 === 0);<br>// Output: true</pre><p><strong>Advanced Use Case:</strong> Checking if any product in a cart is out of stock.</p><pre>const cart = [{ product: &#39;Apple&#39;, inStock: true }, { product: &#39;Banana&#39;, inStock: false }];<br>const anyOutOfStock = cart.some(item =&gt; !item.inStock);<br>// Output: true<br></pre><h3>4. every()</h3><p><strong>Basic Use Case:</strong> Check if all numbers in an array are positive.</p><pre>const numbers = [1, 2, 3, 4, 5];<br>const allPositive = numbers.every(num =&gt; num &gt; 0);<br>// Output: true</pre><p><strong>Advanced Use Case:</strong> Ensuring all fields in a form are valid.</p><pre>const formFields = [<br>{ field: &#39;email&#39;, valid: true },<br> { field: &#39;password&#39;, valid: false }<br>];<br>const formIsValid = formFields.every(field =&gt; field.valid);<br>// Output: false</pre><h3>5. findIndex()</h3><p><strong>Basic Use Case:</strong> Find the index of the first negative number in an array.</p><pre>const numbers = [3, 5, -1, 8];<br>const firstNegativeIndex = numbers.findIndex(num =&gt; num &lt; 0);<br>// Output: 2</pre><p><strong>Advanced Use Case:</strong> Locating the index of a specific object in an array of objects based on a condition.</p><pre>const users = [{ id: 1, name: &#39;Alice&#39; }, { id: 2, name: &#39;Bob&#39; }];<br>const indexOfBob = users.findIndex(user =&gt; user.name === &#39;Bob&#39;);<br>// Output: 1</pre><h3>6. indexOf()</h3><p><strong>Basic Use Case:</strong> Find the first occurrence of a specific element.</p><pre>const fruits = [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;];<br>const bananaIndex = fruits.indexOf(&#39;banana&#39;);<br>// Output: 1</pre><p><strong>Advanced Use Case:</strong> Detecting the first occurrence of a substring within a string.</p><pre>const str = &quot;Hello world, welcome to the universe.&quot;;<br>const indexOfWord = str.indexOf(&quot;welcome&quot;);<br>// Output: 13</pre><h3>7. filter()</h3><p>Basic Use Case: Filter out all numbers less than 10.</p><pre>const numbers = [4, 11, 8, 20, 5];<br>const filtered = numbers.filter(num =&gt; num &gt;= 10);<br>// Output: [11, 20]</pre><p><strong>Advanced Use Case:</strong> Filtering an array of objects, e.g., finding all products within a specific price range.</p><pre>const products = [<br>{ name: &#39;Apple&#39;, price: 1 },<br>{ name: &#39;Banana&#39;, price: 2 }, <br>{ name: &#39;Cucumber&#39;, price: 3 }<br>];<br>const affordableProducts = products.filter(product =&gt; product.price &lt; 3);<br>// Output: [{ name: &#39;Apple&#39;, price: 1 }, { name: &#39;Banana&#39;, price: 2 }]</pre><h3>8. reduce()</h3><p><strong>Basic Use Case:</strong> Sum all numbers in an array.</p><pre>const numbers = [1, 2, 3, 4, 5];<br>const sum = numbers.reduce((total, num) =&gt; total + num, 0);<br>// Output: 15</pre><p><strong>Advanced Use Case:</strong> Calculating the total price of items in a shopping cart.</p><pre>const cart = [<br>{ item: &#39;Apple&#39;, price: 1, quantity: 2 }, <br>{ item: &#39;Banana&#39;, price: 2, quantity: 3 }<br>];<br>const totalCost = cart.reduce((total, item) =&gt; total + item.price * item.quantity, 0);<br>// Output: 8</pre><h3>9. split()</h3><p><strong>Basic Use Case:</strong> Splitting a sentence into words.</p><pre>const sentence = &quot;Hello world, welcome to JavaScript&quot;;<br>const words = sentence.split(&#39; &#39;);<br>// Output: [&quot;Hello&quot;, &quot;world,&quot;, &quot;welcome&quot;, &quot;to&quot;, &quot;JavaScript&quot;]</pre><p><strong>Advanced Use Case:</strong> Extracting the first name and last name from a full name.</p><pre>const fullName = &quot;John Doe&quot;;<br>const [firstName, lastName] = fullName.split(&#39; &#39;);<br>// Output: firstName = &quot;John&quot;, lastName = &quot;Doe&quot;</pre><h3>10. splice()</h3><p><strong>Basic Use Case:</strong> Removing elements from an array.</p><pre>const months = [&#39;Jan&#39;, &#39;March&#39;, &#39;April&#39;, &#39;June&#39;];<br>months.splice(1, 1); // Removes &quot;March&quot;<br>// Output: [&quot;Jan&quot;, &quot;April&quot;, &quot;June&quot;]</pre><p><strong>Advanced Use Case: </strong>Replacing elements in an array.</p><pre>const colors = [&#39;red&#39;, &#39;green&#39;, &#39;blue&#39;];<br>colors.splice(1, 1, &#39;yellow&#39;); // Replaces &quot;green&quot; with &quot;yellow&quot;<br>// Output: [&quot;red&quot;, &quot;yellow&quot;, &quot;blue&quot;]</pre><h3>11. join()</h3><p>Basic Use Case: Join array elements into a string.</p><pre>const elements = [&#39;Fire&#39;, &#39;Air&#39;, &#39;Water&#39;, &#39;Earth&#39;];<br>const combined = elements.join(&#39;,&#39;);<br>// Output: &quot;Fire, Air, Water, Earth&quot;</pre><p><strong>Advanced Use Case:</strong> Creating a CSV string from an array of values.</p><pre>const data = [<br>[&#39;name&#39;, &#39;email&#39;, &#39;age&#39;], <br>[&#39;Alice&#39;, &#39;alice@example.com&#39;, 25]<br> [&#39;Bob&#39;, &#39;bob@example.com&#39;, 30]<br>];<br>const csvString = data.map(row =&gt; row.join(&#39;,&#39;)).join(&#39;\n&#39;);<br>// Output: &quot;name,email,age\nAlice,alice@example.com,25\nBob,bob@example.com,30&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f203f01ffccc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Great article man,]]></title>
            <link>https://medium.com/@aubreyzulu/great-article-man-2d575baa02e7?source=rss-6f16a71992fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d575baa02e7</guid>
            <dc:creator><![CDATA[Aubrey Zulu]]></dc:creator>
            <pubDate>Sun, 14 Mar 2021 06:34:55 GMT</pubDate>
            <atom:updated>2021-03-14T06:34:55.397Z</atom:updated>
            <content:encoded><![CDATA[<p>Great article man,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d575baa02e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>