<?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: Victor Olaoye</title>
    <description>The latest articles on DEV Community by Victor Olaoye (@olaoyevick).</description>
    <link>https://dev.to/olaoyevick</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%2F382324%2F7cfa00d2-4a0f-4fcf-a94b-d04f2affea87.jpg</url>
      <title>DEV Community: Victor Olaoye</title>
      <link>https://dev.to/olaoyevick</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/olaoyevick"/>
    <language>en</language>
    <item>
      <title>Build the Future with the Auto Horizon Developer Challenge</title>
      <dc:creator>Victor Olaoye</dc:creator>
      <pubDate>Sat, 18 Jan 2025 09:11:33 +0000</pubDate>
      <link>https://dev.to/olaoyevick/build-the-future-with-the-auto-horizon-developer-challenge-4609</link>
      <guid>https://dev.to/olaoyevick/build-the-future-with-the-auto-horizon-developer-challenge-4609</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcat33rnzjw90dpv6qlmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcat33rnzjw90dpv6qlmj.png" alt="Image description" width="800" height="1035"&gt;&lt;/a&gt;Developers and AI innovators, it's time to shine. The Auto Horizon Developer Challenge is your opportunity to explore the cutting-edge capabilities of &lt;a href="https://x.com/AutonomysNet" rel="noopener noreferrer"&gt;Autonomys&lt;/a&gt;' Auto SDK, create innovative decentralized apps, and win exciting prizes.&lt;/p&gt;

&lt;p&gt;Whether you're building AI-powered super dApps or agent proof-of-concepts (PoCs), this challenge is the perfect platform to showcase your skills, gain recognition, and win up to $1,000 USDC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Should You Participate?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's why this challenge is unmissable:&lt;/p&gt;

&lt;p&gt;**&lt;br&gt;
**&lt;br&gt;
1st Place: $1,000 USDC&lt;br&gt;
2nd Place: $500 USDC&lt;br&gt;
3rd Place: $300 USDC&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explore the Auto SDK&lt;/strong&gt;&lt;br&gt;
The Auto SDK simplifies the creation of decentralized applications on the Autonomys Network. Features include:&lt;/p&gt;

&lt;p&gt;Auto Drive: Decentralized content-addressed storage for secure data management.&lt;br&gt;
Auto Consensus: Tools for interacting with the Proof-of-Attention Stake (PoAS) consensus layer.&lt;br&gt;
Auto DAG Data: Organize data seamlessly for on-chain storage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Can You Build?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The possibilities are endless:&lt;br&gt;
Market intelligence oracles&lt;br&gt;
Sentiment analysis tools&lt;br&gt;
Prediction agents&lt;br&gt;
Discord bots&lt;br&gt;
Custom digital assistants&lt;/p&gt;

&lt;p&gt;Express your creativity and build something truly unique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Get Started&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Learn the SDK: Check out the &lt;a href="https://docs.autonomys.xyz/develop/auto-sdk/intro" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; and &lt;a href="https://github.com/autonomys/auto-sdk" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Build Your Project: Create an innovative decentralized application or agent using the Auto SDK.&lt;/li&gt;
&lt;li&gt;Make It Open Source: Share your project on GitHub to help others learn and grow.&lt;/li&gt;
&lt;li&gt;Submit Your Entry: Post your project in the Autonomys #developer-chat on Discord or Telegram with:
A GitHub repository link
A live deployment link
A brief project description&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Key Dates&lt;/strong&gt;&lt;br&gt;
Challenge Start: December 18, 2024&lt;br&gt;
Deadline: January 31, 2025&lt;br&gt;
Winners Announced: Two weeks after the deadline&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tips for Success&lt;/strong&gt;&lt;br&gt;
Combine SDK features in unique ways&lt;br&gt;
Test your project thoroughly for reliability&lt;br&gt;
Write clean, well-documented code&lt;br&gt;
Leverage Auto Drive for seamless decentralized storage&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to Join?&lt;/strong&gt;&lt;br&gt;
Don't miss this chance to showcase your skills, connect with like-minded innovators, and win exciting rewards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forum.autonomys.xyz/t/auto-horizon-developer-challenge/4645" rel="noopener noreferrer"&gt;Learn More and Enter Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's build the future, one super dApp at a time!&lt;/p&gt;

</description>
      <category>developers</category>
      <category>ai</category>
      <category>web3</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How To Access And Render Data Attributes With CSS &amp; JavaScript</title>
      <dc:creator>Victor Olaoye</dc:creator>
      <pubDate>Thu, 22 Dec 2022 13:38:31 +0000</pubDate>
      <link>https://dev.to/olaoyevick/how-to-access-and-render-data-attributes-with-css-javascript-12o6</link>
      <guid>https://dev.to/olaoyevick/how-to-access-and-render-data-attributes-with-css-javascript-12o6</guid>
      <description>&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%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AnbrVWK0PkkL-6MOB" 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%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AnbrVWK0PkkL-6MOB"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Goran Ivos on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Data attributes gives us the ability to embed custom data attributes in HTML. According to &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;, data attributes allows us to store extra information on standard semantic HTML elements without other hacks such as non-standard attributes, or extra properties on DOM.&lt;/p&gt;

&lt;p&gt;The beauty of these data attributes is that, it can be accessed in CSS and JavaScript. Let’s see an example of how it works with CSS first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;b data-content="John Doe"&amp;gt;&amp;lt;/b&amp;gt;
&amp;lt;style type="text/css"&amp;gt;
  b::after{
       content: attr(data-content);
  }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;From the above CSS code block, we can see that the ::after pseudo-class selector uses &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/content" rel="noopener noreferrer"&gt;content&lt;/a&gt; property to render the data attribute. In this context, it renders “John Doe” as the data content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also, JavaScript can be used to access and render data attributes on the web page. Let’s see an 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;var name = b.document.getElementById("name");

console.log(name.dataset.parent);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;From the example above, we can see that the data attribute is being accessed with the dataset property and then logged onto the console.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Notable References
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*" rel="noopener noreferrer"&gt;data-* - HTML: HyperText Markup Language | MDN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://html.spec.whatwg.org/multipage/dom.html#domstringmap" rel="noopener noreferrer"&gt;HTML&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sitepoint.com/use-html5-data-attributes/" rel="noopener noreferrer"&gt;How to Use HTML5 Data Attributes - SitePoint&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>dataattribute</category>
    </item>
    <item>
      <title>String Methods In JavaScript</title>
      <dc:creator>Victor Olaoye</dc:creator>
      <pubDate>Sat, 01 Oct 2022 04:47:02 +0000</pubDate>
      <link>https://dev.to/olaoyevick/string-methods-in-javascript-m8a</link>
      <guid>https://dev.to/olaoyevick/string-methods-in-javascript-m8a</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7ZREcvjV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2Afmot_9AivddSmi8Q" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7ZREcvjV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2Afmot_9AivddSmi8Q" alt="A blurry block of JavaScript code on a laptop." width="880" height="586"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Shahadat Rahman on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this article, I’ll be covering different string methods that helps us work with strings in JavaScript. Strings are considered primitives in JavaScript because it’s a single value; JavaScript treats primitives as if they were objects and provides methods to call them.&lt;/p&gt;

&lt;h4&gt;
  
  
  charAt()
&lt;/h4&gt;

&lt;p&gt;The charAt() method is used to return the character at a specified position in a string.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dZRFaDt4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/517/1%2Ar8HYps9HwnqbfHJ0c_tk8g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dZRFaDt4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/517/1%2Ar8HYps9HwnqbfHJ0c_tk8g.png" alt="From the image, I declared a variable called str and assigned “hello world” to it. Using the charAt() method, I did console.log(str.charAt(0)) and it prints ‘h’ to the console" width="517" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the code block in the image, we can see that it prints the first character to the console(“h”). If we want to print the 5th character of a given string to the console, then we replace 0 with 4.&lt;/p&gt;

&lt;h4&gt;
  
  
  concat()
&lt;/h4&gt;

&lt;p&gt;The concat() method was coined from the word concatenate, which means joining two or more strings together. See how it works from this example;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bNdswp5---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/515/1%2ArEDznux0UD8iSPrBqZ3k3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bNdswp5---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/515/1%2ArEDznux0UD8iSPrBqZ3k3w.png" alt="Three different variables were declared with three different strings assigned to them respectively and then the concat() method was used to join the three strings together" width="515" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the example above, two strings were joined together using the concat() method&lt;/p&gt;

&lt;h4&gt;
  
  
  indexOf()
&lt;/h4&gt;

&lt;p&gt;The indexOf() method returns the position of the first occurrence of a value in a string. Let’s see how it works;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5DH-h1y_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/515/1%2AqtFBqRXBHbcJYW2kmFM2Vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5DH-h1y_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/515/1%2AqtFBqRXBHbcJYW2kmFM2Vg.png" alt="A declared variable assigned to a string — “hello join, nice to meet you”. The indexOf() method is used to get the position of “nice” — str.indexOf(“nice”) which prints 12 to the console." width="515" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  lastIndexOf()
&lt;/h4&gt;

&lt;p&gt;Unlike indexOf(), the lastIndexOf() method returns the position of the last occurrence of a value in a string. See the example below;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zN6KMSCH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/532/1%2AoD0HhmEBGS9A_PPYdql9lQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zN6KMSCH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/532/1%2AoD0HhmEBGS9A_PPYdql9lQ.png" alt="A declared variable assigned to a string — “hello join, nice to meet you”. The indexOf() method is used to get the position of “you” — str.lastIndexOf(“you”) which prints 25 to the console." width="532" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Caveat: Both the indexOf() and lastIndexOf() methods are case sensitive.&lt;/p&gt;

&lt;h4&gt;
  
  
  replace()
&lt;/h4&gt;

&lt;p&gt;This is a generic method for replacing and searching. It can also be used with regular expressions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3yqv3bW0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/530/1%2AAN7H6pzcNk-BAvYvDDo4xw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3yqv3bW0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/530/1%2AAN7H6pzcNk-BAvYvDDo4xw.png" alt="A variable assigned to a string — “hello world”, then the replace method is used to replace “world” with “john” — str.replace(“world”, “john”). It prints “hello john” to the console." width="530" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  search()
&lt;/h4&gt;

&lt;p&gt;The search() method returns the position of the first match or -1 if not found. Let’s see how it works in the example below;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6RblfcMF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/524/1%2Ak3s8C2YZCflSqnCGeVIPxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6RblfcMF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/524/1%2Ak3s8C2YZCflSqnCGeVIPxw.png" alt="A variable assigned a string — “hello world”, then the search() method is used to search for the position of “world“ from the string — str.search(“world”). It prints 6 to the console." width="524" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  slice()
&lt;/h4&gt;

&lt;p&gt;The slice()method is just one of the three ways to get a substring in JavaScript and it’s syntax is &lt;strong&gt;slice(start [, end])&lt;/strong&gt;. It returns the extracted part in a new string. For instance;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qEdP_mST--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2AbINRUXCfcsg1Btvsbtjx3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qEdP_mST--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2AbINRUXCfcsg1Btvsbtjx3g.png" alt="A variable assigned to a string — “hello”, then the slice() method is used to return the letters from index 0 to index 4 — str.slice(0, 4). It prints “hell” to the console." width="375" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  substr()
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;substring(start [, end])&lt;/strong&gt; is almost the same as slice — it’s also a way to get substring in JavaScript except that it allows the start to be greater than the end and also allows negative starts. For instance;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g6v3G0b3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/376/1%2APTWC32mO1wDO9UbxazYkBQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g6v3G0b3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/376/1%2APTWC32mO1wDO9UbxazYkBQ.png" alt="A variable assigned a string — “JavaScript”, then the substr() method is used to return the letters from index 4 to index 6— str.substr(4, 6). It prints “Script” to the console." width="376" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  substring()
&lt;/h4&gt;

&lt;p&gt;The substring() method extracts characters, between two indices (positions), from a string, and returns the substring. Let’s see how it works;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hdIy4SiK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/376/1%2Asrl6X5xUrSH9lp0AvrX1DQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hdIy4SiK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/376/1%2Asrl6X5xUrSH9lp0AvrX1DQ.png" alt="A variable assigned a string — “hello world”, then the substring() method is used to return the characters in-between index 5 and index 8- str.substring(5, 8). It prints “wo” to the console." width="376" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  toUpperCase()
&lt;/h4&gt;

&lt;p&gt;It changes the case of all characters in the string to uppercase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jjRi9BGq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2AjMpor_nqqsxHqAAftgKagg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jjRi9BGq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2AjMpor_nqqsxHqAAftgKagg.png" alt="A variable assigned a string — “hello john” all in lowercase, then the toUpperCase() method is used to change every letter in the string to uppercase- str.toUpperCase(). It prints “HELLO JOHN” to the console." width="375" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  toLowerCase()
&lt;/h4&gt;

&lt;p&gt;It’s the direct opposite of the toUpperCase() method. It changes the case of all characters in the string to lowercase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GtDURc7j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/379/1%2AidTzNgLCvxBQDkTHYHQSHQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GtDURc7j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/379/1%2AidTzNgLCvxBQDkTHYHQSHQ.png" alt="A variable assigned a string — “HELLO JOHN” all in uppercase, then the toLowerCase() method is used to change every letter in the string to lowercase- str.toLowerCase(). It prints “hello john” to the console." width="379" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  valueOf()
&lt;/h4&gt;

&lt;p&gt;The valueOf() method is the default method for string, used internally by JavaScript. This method returns the primitive value of a string. The valueOf() method can be used to convert a string object into a string.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QwphKgQF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2AGFvBPnI7YnESw863RQAxBw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QwphKgQF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2AGFvBPnI7YnESw863RQAxBw.png" alt="A variable assigned a string — “Hello World!”, then the valueOf() method is used to get the primitive value of the string - str.valueOf(). It prints “Hello World!” to the console." width="375" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  trim()
&lt;/h4&gt;

&lt;p&gt;This is a very helpful method that removes spaces from the beginning and end of a string. For instance;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZJ8uWB92--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/379/1%2A2PhGxPPG6Ub4pQdsVmLI2A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZJ8uWB92--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/379/1%2A2PhGxPPG6Ub4pQdsVmLI2A.png" alt="A variable assigned a string — “ hello world ” with four tab spaces at the beginning and end of the string, then the trim() method is used to remove the spaces at the beginning and end of the string — str.trim(). It prints “hello world” to the console." width="379" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  toString()
&lt;/h4&gt;

&lt;p&gt;This method returns a string as a string. It can also be used to convert a string object to string. For instance;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TGHPGDpE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/380/1%2Aq84v3_dxoUt5B8F_9PSnUw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TGHPGDpE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/380/1%2Aq84v3_dxoUt5B8F_9PSnUw.png" alt="" width="380" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  split()
&lt;/h4&gt;

&lt;p&gt;The split() method splits a string into an array of substrings and it returns a new array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ez8m0gNb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/383/1%2AxraX0n_h6RyrRMgd7vPzPQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ez8m0gNb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/383/1%2AxraX0n_h6RyrRMgd7vPzPQ.png" alt="Used the .split() method on a string — console.log(‘12–34–56’.split(‘-’)). It prints an array [‘12’, ‘34’, ‘56’]." width="383" height="40"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  charCodeAt()
&lt;/h4&gt;

&lt;p&gt;We can use the charCodeAt() to get the Unicode of any character in a string.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OHuw9x_x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/379/1%2AFwJYRFF3DdZXYjnVsfd5Bg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OHuw9x_x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/379/1%2AFwJYRFF3DdZXYjnVsfd5Bg.png" alt="" width="379" height="40"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  includes()
&lt;/h4&gt;

&lt;p&gt;This method returns true if a string contains a specified string, otherwise it returns false. The includes() method is case sensitive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u9bdpEfc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/383/1%2AAVyvBdUrrkST6SC6cJC7rA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u9bdpEfc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/383/1%2AAVyvBdUrrkST6SC6cJC7rA.png" alt="A variable assigned a string — “Hello World, welcome to the universe!”, then the includes() method is used to determine if the string contains “welcome” — str.includes(“welcome”). It prints true to the console." width="383" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  match()
&lt;/h4&gt;

&lt;p&gt;The match() method finds matches for regular expressions in a string. It has three modes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If the regexp doesn’t have flag g, then it returns the first match as an array with capturing groups and properties index , input (input string, equals str)&lt;/li&gt;
&lt;li&gt;If the regexp has flag g, then it returns an array of all matches as strings, without capturing groups and other details.&lt;/li&gt;
&lt;li&gt;If there are no matches, no matter if there’s flag g or not, null is returned.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s see an example of how this method works below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Px75OzSL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/530/1%2Ah0uWZCVv-oA5IVSxWKJzrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Px75OzSL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/530/1%2Ah0uWZCVv-oA5IVSxWKJzrg.png" alt="A variable assigned a string — “JavaScript TypeScript NativeScript”, then the match() method is used to check if any word from the string matches “Script” — str.match(/Script/g”). It then prints an array of all matches — [‘Script’, ‘Script’, ‘Script’]." width="530" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Summary
&lt;/h4&gt;

&lt;p&gt;In this article, we’ve seen different string methods, their descriptions and how to apply them in JavaScript.&lt;/p&gt;

&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;p&gt;. This whole article was inspired by &lt;a href="https://medium.com/u/984a2bedfdfc"&gt;codingtute&lt;/a&gt; JavaScript string methods cheat sheet I saw a while ago&lt;/p&gt;

&lt;p&gt;. You can also take a look at &lt;a href="https://javascript.info/"&gt;JavaScript.info&lt;/a&gt; to learn more&lt;/p&gt;

&lt;p&gt;. Also, &lt;a href="https://www.w3schools.com/jsref/jsref_obj_string.asp"&gt;w3schools&lt;/a&gt; is also a great resource to learn about strings in-depth.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>datastructures</category>
      <category>stringinjavascript</category>
    </item>
    <item>
      <title>Difference Between Local And Global State Management In React</title>
      <dc:creator>Victor Olaoye</dc:creator>
      <pubDate>Thu, 08 Sep 2022 11:02:57 +0000</pubDate>
      <link>https://dev.to/olaoyevick/difference-between-local-and-global-state-management-in-react-3fon</link>
      <guid>https://dev.to/olaoyevick/difference-between-local-and-global-state-management-in-react-3fon</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q2pX0OXn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AM2u_Pu19uJz-HIEI" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q2pX0OXn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AM2u_Pu19uJz-HIEI" alt="" width="880" height="584"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Kit Suman on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;State management is a programming technique that is very essential in any web application. It involves managing dynamic piece of information that makes the user interface of any app interactive thus, making the user experience swift.&lt;/p&gt;

&lt;p&gt;When interacting with web applications, there are different noticeable changes in the UI, ranging from toggling the navbar to adding products to carts. These are all possible with state management techniques. State management can be very complex depending on the scale of the application. In recent years, there have been a lot of ways for managing state. In this article, we’ll look at the difference between local and global state management in react.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local State Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In local state management, the application state(dynamic information that will keep the user’s experience as smooth as possible) is component scoped. Keep in mind that while managing states in React, states can only be passed as a prop to the child component (&lt;a href="https://www.geeksforgeeks.org/unidirectional-data-flow/"&gt;unidirectional data flow&lt;/a&gt;), but we can’t do the same for the parent component. This unidirectional data flow in react makes local state management easy.&lt;/p&gt;

&lt;p&gt;A real-life example of local state management is an application that increases count when a button is clicked. The state of the application is within that component. useState and useReducer hooks can easily be used to manage the state.&lt;/p&gt;

&lt;p&gt;But then, what if the states of a large-scale application needs to be managed across all components, for example an e-commerce site where users can add products to cart in a component and display the number of products added in the header component, using useState &amp;amp; useReducer hooks will only make things complex; this is will be explained in the next section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global State Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Managing a large scale application in the scenario given above, will mean that state will be shared across all components. Since there’s no connection between the cart component and the header component, how do we get the number of products added to cart displayed on the header component?.&lt;/p&gt;

&lt;p&gt;In this case, it is recommended to avoid passing of data through several nested children components (&lt;a href="https://www.geeksforgeeks.org/what-is-prop-drilling-and-how-to-avoid-it/"&gt;prop drilling&lt;/a&gt;), many libraries have been created to sort this issue: Redux, MobX and so on. React itself also created a hook called Context APIs which can be used to manage global states in web application.&lt;/p&gt;

&lt;p&gt;In this article, we have now seen how to manage states both locally and globally with React hooks and other libraries to make our applications very interactive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notable References&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/context.html"&gt;Context - React&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redux.js.org/"&gt;Redux - A predictable state container for JavaScript apps. | Redux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/state-and-lifecycle.html"&gt;State and Lifecycle - React&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mobx.js.org/react-integration.html"&gt;React integration · MobX&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
      <category>statemanagement</category>
    </item>
    <item>
      <title>Error: useParams Not Destructuring In Typescript</title>
      <dc:creator>Victor Olaoye</dc:creator>
      <pubDate>Sat, 03 Sep 2022 15:35:54 +0000</pubDate>
      <link>https://dev.to/olaoyevick/error-useparams-not-destructuring-in-typescript-3m4f</link>
      <guid>https://dev.to/olaoyevick/error-useparams-not-destructuring-in-typescript-3m4f</guid>
      <description>&lt;p&gt;I've seen this error in the code block below cause issues for developers who are just starting out with TypeScript. I'm going to show you how to solve this error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { token } = useParams();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, you need to be aware that typescript can't destructure generic plain objects like &lt;code&gt;{}&lt;/code&gt; which means useParams() is a generic. Peradventure, you might have also tried using this code block below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { token } = useParams() as any
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code block above is very wrong because &lt;code&gt;any&lt;/code&gt; can't just be thrown around in this case. The keyword &lt;code&gt;any&lt;/code&gt; should only be used when the object can be of any type, in our case here we know the properties and the type of our object, therefore, &lt;code&gt;any&lt;/code&gt; shouldn't be used in this scenario.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Side Note: If you know anything about the property of your object or what it will hold, then the keyword &lt;code&gt;any&lt;/code&gt; shouldn't be used. It defeats the entire purpose of using typescript in this context.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, you might be wondering; what is the best possible solution. You need to tell TypeScript the value of the generic. Say, the value of our generic is a string. Then we write it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { token } = useParams&amp;lt;{token?: string}&amp;gt;()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above code, we're simply telling TypeScript that the value of our token is either a string or undefined. The &lt;code&gt;?&lt;/code&gt; in our code is an optional operating chaining operator in TypeScript. By now, your error should have been solved and doubts cleared.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>react</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
