<?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 Abraham Esparza on Medium]]></title>
        <description><![CDATA[Stories by Abraham Esparza on Medium]]></description>
        <link>https://medium.com/@abrahamesparza.us?source=rss-98a9bfa7be5f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*uSZSCNa9cKUS1o0F</url>
            <title>Stories by Abraham Esparza on Medium</title>
            <link>https://medium.com/@abrahamesparza.us?source=rss-98a9bfa7be5f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:58:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abrahamesparza.us/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[create a phone number]]></title>
            <link>https://medium.com/@abrahamesparza.us/create-a-phone-number-bd8e6b1bf5f?source=rss-98a9bfa7be5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd8e6b1bf5f</guid>
            <category><![CDATA[solutions]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[codewars]]></category>
            <category><![CDATA[mdn]]></category>
            <dc:creator><![CDATA[Abraham Esparza]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 18:35:49 GMT</pubDate>
            <atom:updated>2020-06-19T18:35:49.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*ZyAQGmuneRkgDr1npa6NDw.png" /></figure><p>Today I am going to go over a toy problem I tackled from Codewars.com</p><p>I am making it a new habit of mine to solve at least one coding challenge a day — then write about that problem.</p><p>Today’s toy problem I solved was <strong>createPhoneNumber. </strong>Given an input of an array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] — I needed to return an output “(123) 456–7890”. Fairly simple problem. I decided to write about this toy problem, because I was inspired by another solution I saw after submitting mine.</p><p>The solution that inspired me used the <strong>.replace()</strong> method. I have never used this method, but after seeing how simple the solution was with this method — I was inspired to write about it and carry this method with me in the future.</p><p>My solution to this problem was:</p><blockquote>function createPhoneNumber(numbers) {<br> let areaCode = ‘’;<br> let prefix = ‘’;<br> let ending = ‘’;</blockquote><blockquote>let area = numbers.slice(0, 3);<br> let pre = numbers.slice(3, 6);<br> let end = numbers.slice(6, 10);</blockquote><blockquote>pre.push(‘-’);<br> area.unshift(‘(‘);<br> area.push(‘)’);<br> for (let num in area) {<br> areaCode += area[num];<br> }<br> for (let num in pre) {<br> prefix += pre[num];<br> }<br> for (let num in end) {<br> ending += end[num];<br> }<br> return areaCode.concat(‘ ‘, prefix).concat(ending);<br>}<br>createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])</blockquote><blockquote>The solution that inspired me looked like:<br>function createPhoneNumber(numbers) {<br> let phoneNumber = ‘(xxx) xxx-xxx’;<br> for (let num in numbers) {<br> phoneNumber = phoneNumber.replace(‘x’, numbers[num]);<br> }<br> return phoneNumber;<br>}<br>createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])</blockquote><p>The simplicity and minimalism in the second solution amazes me. I thought I’d share this with the world. Discovering new ways to solve problems is astounding and I’m glad I am able to share what I learned with you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd8e6b1bf5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>