<?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>Forem: Vick Greenfields</title>
    <description>The latest articles on Forem by Vick Greenfields (@akintoluvic).</description>
    <link>https://forem.com/akintoluvic</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%2F123071%2F31df3759-eeee-4ea4-90a7-4b96c9344545.jpg</url>
      <title>Forem: Vick Greenfields</title>
      <link>https://forem.com/akintoluvic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/akintoluvic"/>
    <language>en</language>
    <item>
      <title>The Use of Intl Keyword in JavaScript</title>
      <dc:creator>Vick Greenfields</dc:creator>
      <pubDate>Thu, 16 Mar 2023 10:11:21 +0000</pubDate>
      <link>https://forem.com/akintoluvic/the-use-of-intl-keyword-in-javascript-1cl5</link>
      <guid>https://forem.com/akintoluvic/the-use-of-intl-keyword-in-javascript-1cl5</guid>
      <description>&lt;p&gt;Intl in Javascript is a set of tools used in enabling the design and development of an application or document that enables easy usage for target audiences in different cultures, regions or language.&lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl"&gt;MDN&lt;/a&gt;, the Intl object is the namespace for the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting.&lt;/p&gt;

&lt;p&gt;In this article, I will show you how to format date, time and numbers as well as other &lt;code&gt;Intl&lt;/code&gt; built in functionalities for comparing strings without the use of any libraries or plugins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Intl syntax
&lt;/h2&gt;

&lt;p&gt;The Intl object provides access to several constructors as well as functionality common to the internationalization constructors and other language sensitive functions (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl"&gt;MDN&lt;/a&gt;). Available constructors on the Intl object includes but not limited to NumberFormat, DateTimeFormat, Collator and RelativeTimeFormat.&lt;/p&gt;

&lt;p&gt;These constructors and methods all accepts &lt;code&gt;locale&lt;/code&gt; and &lt;code&gt;options&lt;/code&gt; as arguments. The &lt;code&gt;locale&lt;/code&gt; argument stands for the location to be used in carrying out an operation. Its value can be a string, undefined (when it is not provided, in which case the implementation's default value is used) or an array of locations (in which case, the first is chosen and others are fallbacks).&lt;/p&gt;

&lt;p&gt;For the full list of supported options, consult &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#see_also:~:text=%23%20intl%2Dobject-,Browser%20compatibility,-Report%20problems%20with"&gt;mdn web docs&lt;/a&gt;. The structure for creating a new instance of the Intl object is shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myIntlFormat = new Intl.[constructor](locale, {options})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Based on operations to be performed, either NumberFormat, DateTimeFormat, Collator or RelativeTimeFormat can be passed in as the constructor as demonstrated below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myIntlNumberFormat = new Intl.NumberFormat(locale, {options})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage of the new instance created can then be done by appending the &lt;code&gt;.format()&lt;/code&gt; function and passing the value to be formatted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myIntlNumberFormat.format(23423.23)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Formatting Currencies
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Intl.NumberFormat&lt;/code&gt; object can be used to format numbers to currencies based on a user's locale. This is demonstrated below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myNumber = 1452342.783
let formatNumberToCurrency = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'USD'
})

console.log(formatNumberToCurrency.format(myNumber)) // '$1,452,342.78'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, we are creating a new instance of the &lt;code&gt;Intl.NumberFormat&lt;/code&gt; and passing the options of style and currencies to be formatted with. The formatter then uses that to format &lt;code&gt;myNumber&lt;/code&gt; with the appropriate currency, decimal places and comma-separators as needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Number Formatting
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Intl.NumberFormat&lt;/code&gt; object enables the formating of numbers based on a user's location and language (without adding currencies) as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myNumber = 1452342.783
let formatNumber = new Intl.NumberFormat('en-US')

console.log(formatNumber.format(myNumber)) // '1,452,342.78'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Date Format
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Intl.DateTimeFormat&lt;/code&gt; object is useful for formating date and time based on the user's location. This requires passing in the locale code as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myDate = new Date()
let formatDate = new Intl.DateTimeFormat('en-US')

console.log(formatDate.format(myDate)) // '23/2/2023'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Collating and Sorting
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Intl.Collator&lt;/code&gt; object provides support for comparing and sorting of strings. This can be used to compare and sort strings based on the locale values provided. The Intl.Collator is used to sort an array of strings in the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myArray = ['Vick', 'Greene', 'Adele']
let myColator = new Intl.Collator('en-US')

console.log(myArray.sort(myColator.compare)) // ['Adele', 'Greene', 'Vick']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will notice that the syntax is different from the other ones above. Using Intl.collator requires using the &lt;code&gt;.sort()&lt;/code&gt; function and passing the our colator object and appending it with &lt;code&gt;.compare&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Relative Time Formats
&lt;/h2&gt;

&lt;p&gt;Intl also support for generating relative time formats for dates thereby reducing the use of libraries for this since it is built into javascript already. &lt;code&gt;Intl.RelativeTimeFormat&lt;/code&gt; takes &lt;code&gt;locale&lt;/code&gt; value and a variety of options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let relativeTimeFormatter = new Intl.RelativeTimeFormat('en', {
    numeric: 'auto'
})

console.log(relativeTimeFormatter.format(1, 'week')) // 'next week'
console.log(relativeTimeFormatter.format(-3, 'year')) // '3 years ago'
console.log(relativeTimeFormatter.format(2, 'hour')) // 'in 2 hours'

// In German
let germanTimeFormatter = new Intl.RelativeTimeFormat('es', {
    numeric: 'auto'
})
console.log(germanTimeFormatter.format(1, 'week')) // 'nächste Woche'
console.log(germanTimeFormatter.format(-3, 'year')) // 'vor 3 Jahren'
console.log(germanTimeFormatter.format(2, 'hour')) // 'in 2 Stunden'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see above, it supports both negative and positive values for dates whether in the past or in the future. And it also cancels the need for hardcoding string values, which can be quite difficult to do if you support lots of languages.&lt;/p&gt;

&lt;p&gt;Supported units that can be passed in includes &lt;code&gt;second&lt;/code&gt;, &lt;code&gt;minute&lt;/code&gt;, &lt;code&gt;hour&lt;/code&gt;, &lt;code&gt;day&lt;/code&gt;, &lt;code&gt;week&lt;/code&gt;, &lt;code&gt;month&lt;/code&gt;, &lt;code&gt;quater&lt;/code&gt; and &lt;code&gt;year&lt;/code&gt;. You can read more about it's usage and how to extend it &lt;a href="https://www.builder.io/blog/relative-time"&gt;here&lt;/a&gt; and on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl"&gt;MDN&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Intl is a powerful tool that makes it easy to format and display data in a way that users can understand based on each user’s location. using it, empowers you to provide localized and consistent experience for your users across different countries and languages.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Recursion Illustrated with PseudoCode and Code</title>
      <dc:creator>Vick Greenfields</dc:creator>
      <pubDate>Sun, 14 Jun 2020 15:01:28 +0000</pubDate>
      <link>https://forem.com/akintoluvic/recursion-illustrated-with-pseudocode-and-code-677</link>
      <guid>https://forem.com/akintoluvic/recursion-illustrated-with-pseudocode-and-code-677</guid>
      <description>&lt;h2&gt;
  
  
  WHAT IS RECURSION?
&lt;/h2&gt;

&lt;p&gt;The simplest definition of recursion is simply when a function solves a problem by calling itself. Confusing right? Yes and no. I am going to illustrate how recursion works in both real life and in javascript in order to make things clearer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3wgzsdk9jgcwjy0gdior.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3wgzsdk9jgcwjy0gdior.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HUNGER ILLUSTRATION
&lt;/h2&gt;

&lt;p&gt;Imagine that you are hungry now and you will like to eat 'Jollof Rice'. Let us write the solution in pseudo code&lt;/p&gt;

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

 First you need to dish the Jollof Rice
      then you need to eat the Jollof rice


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In Javascript, the code will look like this.&lt;/p&gt;

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

function eat(food) {
    dish(food)
    eatFood();
}
if(hungry) {
    eat('Jollof Rice')
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If hungry is true, to eat, you dish the food and start eating. Simple right?&lt;/p&gt;

&lt;p&gt;Except eating is not that simple. It involves carrying the rice with fork and chewing it before swallowing it.&lt;/p&gt;

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

function eat(food) {
    dish(food)
    eatFood()
}

function eatFood() {
    carryForkOfRice()
    chewAndSwallow()
}

if(hungry) {
    eat('Jollof Rice')
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And then again and again, you carry fork and chew, the process only stops when you are satisfied. One spoonfull can not possible satisfy you right? You need to do it again and again. And that is why recursion comes in, the eat food function has to keep calling itself for the hunger to quench. Which means your eat food function has now gone &lt;strong&gt;recursive&lt;/strong&gt; as it now calls itself over and over.&lt;/p&gt;

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

function eatFood() {
    carryForkOfRice()
    chewAndSwallow()
    eatFood()
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But just as a computer has a limited memory, in the same way, your stomach can only take a sizeable amount of food. Which means your brain has to check after each for of rice whether you are satiated or not, in order to prevent overfeeding. This we implement by checking if you are satiated after swallowing food.&lt;/p&gt;

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

function eatFood() {
    carryForkOfRice()
    chewAndSwallow()
    if(satiated) {
        return
    } else {
        eatFood()
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In programming, a recursive function will continue to run perpetually until the computer runs out of memory. To prevent this, a breaking comdition is set. A good example is the if satiated clause condition in our eat food condition above.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>recursion</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Bug on Timbu.com</title>
      <dc:creator>Vick Greenfields</dc:creator>
      <pubDate>Tue, 02 Apr 2019 14:10:39 +0000</pubDate>
      <link>https://forem.com/akintoluvic/bug-on-timbu-com-186g</link>
      <guid>https://forem.com/akintoluvic/bug-on-timbu-com-186g</guid>
      <description>&lt;p&gt;&lt;a href="https://timbu.com/#"&gt;Timbu&lt;/a&gt; is a travel site that helps travellers plan their trips. It has database for all top travel destinations, homes and hotels. &lt;/p&gt;

&lt;p&gt;However, the site has a bug in the &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---UGyh8s0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/whrojeslxffkiw5729ty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---UGyh8s0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/whrojeslxffkiw5729ty.png" alt="Exclusive offers"&gt;&lt;/a&gt; section of the site. As you can see in the picture the section doesn't display properly on mobile. You can check out &lt;a href="https://timbu.com/#"&gt;Timbu&lt;/a&gt; yourself. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Timbu goes bug hunting </title>
      <dc:creator>Vick Greenfields</dc:creator>
      <pubDate>Tue, 02 Apr 2019 08:16:05 +0000</pubDate>
      <link>https://forem.com/akintoluvic/timbu-goes-bug-hunting-4i0m</link>
      <guid>https://forem.com/akintoluvic/timbu-goes-bug-hunting-4i0m</guid>
      <description>&lt;p&gt;Timbu.com, a travel site that helps travellers plan their trips has opened their doors to bug hunters. The site connects travellers to homes and hotels all over the world. &lt;br&gt;
This move by Timbu.com was made to fix several bugs on the site. Check out the site &lt;a href="https://timbu.com/"&gt;https://timbu.com/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>travelbugsweb</category>
    </item>
    <item>
      <title>My 2019 Goals! Not too late to Start </title>
      <dc:creator>Vick Greenfields</dc:creator>
      <pubDate>Fri, 01 Feb 2019 13:34:27 +0000</pubDate>
      <link>https://forem.com/akintoluvic/my-2019-goals-not-too-late-to-start--f1f</link>
      <guid>https://forem.com/akintoluvic/my-2019-goals-not-too-late-to-start--f1f</guid>
      <description>&lt;p&gt;Your greatest limitation is your last achievement said one of my mentors. 2018 was great, I had a few success stories some of which I hope to discuss in another article. But this made  me take it slow towards the end of last year, forgetting that the quest for greatness has just started. &lt;/p&gt;

&lt;p&gt;Now, am back and invite you to join me on this 2019 journey to achieve my 10 goals for 2019: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get a new laptop &lt;/li&gt;
&lt;li&gt;Become a Badass Frontend Web Developer
&lt;/li&gt;
&lt;li&gt;Become an Intern, then get a Remote Job&lt;/li&gt;
&lt;li&gt;Build my portfolio website&lt;/li&gt;
&lt;li&gt; Finish @freeCodeCamp curriculum&lt;/li&gt;
&lt;li&gt;Contribute to open source project&lt;/li&gt;
&lt;li&gt; Finish #100DaysOfCode &amp;amp; #301DaysOfCode&lt;/li&gt;
&lt;li&gt;Publish an article on Dev.to monthly&lt;/li&gt;
&lt;li&gt;Give a Dev talk&lt;/li&gt;
&lt;li&gt;Start working out&lt;/li&gt;
&lt;li&gt;Get/build a Solar Powered Apartment&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>2019goals</category>
    </item>
  </channel>
</rss>
