<?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: Kevin Coto🚀💡</title>
    <description>The latest articles on DEV Community by Kevin Coto🚀💡 (@kevincoto).</description>
    <link>https://dev.to/kevincoto</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%2F632883%2F871ba5f7-ba57-4db8-8bcd-c650dc315719.jpg</url>
      <title>DEV Community: Kevin Coto🚀💡</title>
      <link>https://dev.to/kevincoto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevincoto"/>
    <language>en</language>
    <item>
      <title>Using Cloudflare Turnstile with SvelteKit: A Simple Guide</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Sun, 30 Mar 2025 15:29:59 +0000</pubDate>
      <link>https://dev.to/kevincoto/using-cloudflare-turnstile-with-sveltekit-a-simple-guide-398k</link>
      <guid>https://dev.to/kevincoto/using-cloudflare-turnstile-with-sveltekit-a-simple-guide-398k</guid>
      <description>&lt;p&gt;This post explains how to integrate &lt;strong&gt;Cloudflare Turnstile&lt;/strong&gt; with a SvelteKit form using &lt;code&gt;use:enhance&lt;/code&gt;, ensuring multiple submissions work correctly.  &lt;/p&gt;




&lt;h2&gt;
  
  
  🔹 Step 1: Validate Turnstile Tokens on the Server
&lt;/h2&gt;

&lt;p&gt;To prevent spam, we must verify Turnstile tokens on the backend before accepting form submissions.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Backend (&lt;code&gt;+page.server.ts&lt;/code&gt; or &lt;code&gt;+server.ts&lt;/code&gt;)&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;SECRET_TURNSTILE_KEY&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$env/static/private&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;validateToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://challenges.cloudflare.com/turnstile/v0/siteverify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/x-www-form-urlencoded&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SECRET_TURNSTILE_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;token&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="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;actions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cf-turnstile-response&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;validateToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&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="na"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid CAPTCHA&lt;/span&gt;&lt;span class="dl"&gt;'&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="na"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Form submitted successfully&lt;/span&gt;&lt;span class="dl"&gt;'&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;h3&gt;
  
  
  &lt;strong&gt;What This Does:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Extracts the Turnstile response token from &lt;code&gt;formData&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Sends it to Cloudflare for verification.
&lt;/li&gt;
&lt;li&gt;Rejects the request if the token is invalid.
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🔹 Step 2: Integrate Turnstile in the Svelte Frontend
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Frontend (&lt;code&gt;+page.svelte&lt;/code&gt;)&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight svelte"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"ts"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Turnstile&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svelte-turnstile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;enhance&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$app/forms&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;showCaptcha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$props&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="nf"&gt;$effect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Hide and re-show the CAPTCHA to allow multiple submissions&lt;/span&gt;
            &lt;span class="nx"&gt;showCaptcha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;showCaptcha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&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;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt; &lt;span class="na"&gt;use:enhance&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;#if&lt;/span&gt; &lt;span class="nx"&gt;showCaptcha&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;Turnstile&lt;/span&gt; &lt;span class="na"&gt;siteKey=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VITE_TURNSTILE_SITEKEY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;  &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;/if&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔹 Why &lt;code&gt;$effect(() =&amp;gt; { showCaptcha = false; setTimeout(() =&amp;gt; (showCaptcha = true), 0); })&lt;/code&gt;?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Problem:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When using &lt;code&gt;use:enhance&lt;/code&gt;, SvelteKit &lt;strong&gt;does not reload the page&lt;/strong&gt; after form submission. However, Cloudflare Turnstile &lt;strong&gt;only allows a token to be used once&lt;/strong&gt;. If you try submitting the form again without refreshing, Turnstile will reject the request.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Solution:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;After a successful submission, &lt;code&gt;showCaptcha = false&lt;/code&gt; hides the Turnstile component.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setTimeout(() =&amp;gt; (showCaptcha = true), 0);&lt;/code&gt; forces a re-render, generating a new token.
&lt;/li&gt;
&lt;li&gt;This allows &lt;strong&gt;multiple form submissions without a full page refresh&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🎯 Summary
&lt;/h2&gt;

&lt;p&gt;✅ &lt;strong&gt;Server-side token validation&lt;/strong&gt; prevents spam.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Frontend integration&lt;/strong&gt; with &lt;code&gt;svelte-turnstile&lt;/code&gt; ensures security.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;&lt;code&gt;showCaptcha&lt;/code&gt; reset trick&lt;/strong&gt; allows multiple submissions when using &lt;code&gt;use:enhance&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;Now your SvelteKit form is &lt;strong&gt;secure, user-friendly, and supports multiple submissions seamlessly!&lt;/strong&gt; 🚀&lt;/p&gt;

&lt;p&gt;Check out the full source code on &lt;strong&gt;&lt;a href="https://github.com/KevinCotoCarrera/SvelteKit_Turnstile" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For more look into &lt;a href="//thekoto.dev/blog"&gt;thekoto.dev/blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>captcha</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Yeah Leetcode without Google or LLM Part 1 (35. Search Insert Position)</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Fri, 14 Mar 2025 19:50:34 +0000</pubDate>
      <link>https://dev.to/kevincoto/yeah-leetcode-without-google-or-llm-part-1-35-search-insert-position-4gpl</link>
      <guid>https://dev.to/kevincoto/yeah-leetcode-without-google-or-llm-part-1-35-search-insert-position-4gpl</guid>
      <description>&lt;p&gt;The problem is &lt;a href="https://leetcode.com/problems/search-insert-position/description/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  My Solution:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;searchInsert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&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="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;My path of thinking:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Place a guard in case the first element is equal to the target.&lt;/li&gt;
&lt;li&gt;Check if the nums[i] is less than target return i(works for few cases&lt;/li&gt;
&lt;li&gt;Check also if the the following index in the array is bigger than target so we can place target in the middle&lt;/li&gt;
&lt;li&gt;In some cases there's not following index, check with i+1===nums.length if we are going out of bound&lt;/li&gt;
&lt;li&gt;In default case where target is the lowest just return 0&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;It's slow, really slow. We should be doing Binary Search something that I've used in the past yes but it doesn't come natural.&lt;/p&gt;

&lt;p&gt;Takeaway: Study and apply Binary Search&lt;br&gt;
For more look into &lt;a href="//thekoto.dev/blog"&gt;thekoto.dev/blog&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Destructuring in function parameters</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Wed, 28 Aug 2024 03:04:44 +0000</pubDate>
      <link>https://dev.to/kevincoto/destructuring-in-function-parameters-5gkb</link>
      <guid>https://dev.to/kevincoto/destructuring-in-function-parameters-5gkb</guid>
      <description>&lt;p&gt;Let's say I have a project in three.js and I need some geometries, I will hardcode an array of objects that will contain their x,y, and z, values as well as their width, height, and depth values but this array could be coming from the server or third-party APIs =&amp;gt;&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="nx"&gt;geometriesRaw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;0x44aa88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;z&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;0x8844aa&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&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="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;z&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;width&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="na"&gt;height&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="na"&gt;depth&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="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I will render them using the Array. map function =&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cubes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;geometriesRaw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;mesh&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;boxGeometry&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;meshPhongMaterial&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/mesh&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;})&lt;/span&gt; 

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

&lt;/div&gt;



&lt;p&gt;In just a glance we can realize the verbosity of this code, repeating the argument cube every time.&lt;br&gt;
Another red flag is the no clarity on what properties we're using from the array, for example, z is 0 in both cases and it will probably be zero in the vast majority of cases.&lt;br&gt;
For our regular use case, we shouldn't expose this property to our function, this could also happen frequently with the depth property.&lt;/p&gt;

&lt;p&gt;For that reason, the best option will be destructuring the properties coming from the array of objects as follows =&amp;gt;&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="nx"&gt;cubes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;geometriesRaw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;mesh&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;boxGeometry&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;meshPhongMaterial&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/mesh&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;})&lt;/span&gt; 

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

&lt;/div&gt;



&lt;p&gt;Now we're just using x,y, width, color. This way we're implying that z, height, and depth are default properties inside our function and we don't need them from the data coming from our server or third-party&lt;/p&gt;

&lt;p&gt;This way we're hiding properties for future devs that will interact with our cubes' constant, just showing them the ones we need from an external source and the ones we are setting as the default for better practice we can even write &lt;br&gt;
&lt;code&gt;const z = 0&lt;/code&gt;&lt;br&gt;
...&lt;br&gt;
inside our function to make it even clearer&lt;/p&gt;

&lt;p&gt;For more look into &lt;a href="//thekoto.dev/blog"&gt;thekoto.dev/blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>From software developer to waiter in Dubai</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Wed, 28 Aug 2024 02:31:10 +0000</pubDate>
      <link>https://dev.to/kevincoto/from-software-developer-to-waiter-in-dubai-gfe</link>
      <guid>https://dev.to/kevincoto/from-software-developer-to-waiter-in-dubai-gfe</guid>
      <description>&lt;h2&gt;
  
  
  My Journey in Dubai
&lt;/h2&gt;

&lt;p&gt;I've recently moved to Dubai, the city of luxury we all know well, but I didn't come here as a wealthy guy; I'm broke.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background
&lt;/h3&gt;

&lt;p&gt;I'm a software engineer from the Caribbean island of Cuba, a communist country with 64 years of dictatorship. As you can imagine, the average salary for engineers there ranges from $500 to $1000 per month. Some don't even earn $100; the majority, while a few can make more than $2000. I was earning $1000 to $1200 before coming here.&lt;/p&gt;

&lt;p&gt;My savings were limited, which is a challenge in a city as expensive as Dubai. But for me, life didn't give me any other option. It was either to risk it or continue being unhappy with no bright future.&lt;/p&gt;

&lt;h3&gt;
  
  
  Residency Challenges
&lt;/h3&gt;

&lt;p&gt;Residency in Dubai is a complicated topic. With good luck, it might be easy to get, but in reality, it's more complex. Scams, companies playing with your legal status, and the fact that being here without legal status is something you'd want to avoid make it a tough journey.&lt;/p&gt;

&lt;p&gt;For that reason, I accepted the first job opportunity that came my way: a role as a waiter in a fine-dining Italian restaurant that was about to open in a month and a half. It seemed like the perfect opportunity to make a living in a field far from software engineering, disconnect for a while, and get more than a month of training before starting.&lt;/p&gt;

&lt;p&gt;For the first time, I felt relief. I had a job, a contract, a legal status in process, and a decent salary to make a living.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tears and Joy
&lt;/h3&gt;

&lt;p&gt;Now it was time to prove that I could grind in another field. The first days were so easy, and I felt comfortable. There were just theory training sessions about the food menu—a piece of cake, I'd say. But then the days began escalating in difficulty: role plays, serving tables, guidelines, rules, clearing tables, handling dishes.&lt;/p&gt;

&lt;p&gt;I did well, focusing on being marked as a good waiter. After a few role-plays with feedback, I hit a wall. I did one awful role-play the worst service you could ever imagine. Every step was wrong, from my attitude to my posture everything.&lt;/p&gt;

&lt;p&gt;I got burned out. I was so frustrated, I just sat there, staring into space, feeling my energy and motivation being sucked out of me.&lt;/p&gt;

&lt;p&gt;After that, training continued, and there were exams. Luckily, I passed them all. I was marked as one of the most hard-working team members. I was happy my efforts were bringing results.&lt;/p&gt;

&lt;p&gt;We've been doing some shifts in another restaurant from the same company to learn and make us feel more prepared for the big opening.&lt;/p&gt;

&lt;p&gt;There have been ups and downs, discussions, and tears, but in the end, I feel a personal improvement since I began.&lt;/p&gt;

&lt;p&gt;My story in Dubai is just beginning. I'll keep posting my experiences here. Thanks to anyone who took the time to read this.&lt;/p&gt;

&lt;p&gt;See you soon ;)&lt;/p&gt;

&lt;p&gt;For more look into &lt;a href="//thekoto.dev/blog"&gt;thekoto.dev/blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Vue Shorthand for Slots</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Mon, 20 Jun 2022 22:25:54 +0000</pubDate>
      <link>https://dev.to/kevincoto/a-vue-shorthand-for-slots-ndh</link>
      <guid>https://dev.to/kevincoto/a-vue-shorthand-for-slots-ndh</guid>
      <description>&lt;p&gt;Named Slots has a shorthand that isn't necessarily shorter but maybe cleaner.&lt;/p&gt;

&lt;p&gt;This is the regular way:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Todo&amp;gt;&lt;br&gt;
   &amp;lt;template :description&amp;gt;&lt;br&gt;
   &amp;lt;Item/&amp;gt;&lt;br&gt;
   &amp;lt;/template&amp;gt;&lt;br&gt;
   &amp;lt;/Todo&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the cleaner way:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Todo&amp;gt;&lt;br&gt;
   &amp;lt;template #description&amp;gt;&lt;br&gt;
   &amp;lt;Item/&amp;gt;&lt;br&gt;
   &amp;lt;/template&amp;gt;&lt;br&gt;
   &amp;lt;/Todo&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/thekotodev" rel="noopener noreferrer"&gt;Follow me on Twitter&lt;/a&gt; to get more pieces of advice about Vue.js&lt;/p&gt;

&lt;p&gt;For more look into &lt;a href="//thekoto.dev/blog"&gt;thekoto.dev/blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>slot</category>
    </item>
    <item>
      <title>Simple guide of Flexbox in Real Life🔥Part #2</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Fri, 18 Jun 2021 03:04:17 +0000</pubDate>
      <link>https://dev.to/kevincoto/simple-guide-of-flexbox-in-real-life-part-2-4pf0</link>
      <guid>https://dev.to/kevincoto/simple-guide-of-flexbox-in-real-life-part-2-4pf0</guid>
      <description>&lt;p&gt;If you have come until here you are prepared for working with &lt;strong&gt;Flexbox in real projects&lt;/strong&gt;, but first read all this article.&lt;/p&gt;

&lt;h2&gt;An interesting property: wrap&lt;/h2&gt;

&lt;p&gt;First, we let's talk about the &lt;code&gt;wrap&lt;/code&gt;, &lt;code&gt;wrap&lt;/code&gt; is so useful property to defined If our items it adjusting in one line or allow the items to wrap as needed with this property.&lt;/p&gt;

&lt;p&gt;It has 3 properties:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nowrap&lt;/code&gt; (default): all flex items will be on one line&lt;br&gt;
&lt;code&gt;wrap&lt;/code&gt;: flex items will wrap onto multiple lines, from top to bottom.&lt;br&gt;
&lt;code&gt;wrap-reverse&lt;/code&gt;: flex items will wrap onto multiple lines from bottom to top.&lt;/p&gt;

&lt;h2&gt;A combination between &lt;code&gt;wrap&lt;/code&gt; and &lt;code&gt;flex-direction&lt;/code&gt;: &lt;code&gt;flow&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If you needed use flex-direction and wrap in the same element, so flow is your solution to save your time and create more clarity and professional code&lt;/p&gt;

&lt;p&gt;This is an example of how use this property:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.div {&lt;br&gt;
  flex-flow: column wrap;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I know that you are waiting for more property but I'm sorry it does not have more so important properties, If you want to read more about all flexbox properties clicking this &lt;a href="https://yourlink.cc/a-complete-guide-to-flexbox" rel="noopener noreferrer"&gt;URL&lt;/a&gt;, sorry it's a monetizable URL with them I pay my tomatoes&lt;/p&gt;

</description>
      <category>css</category>
      <category>flexbox</category>
      <category>javascript</category>
      <category>responsive</category>
    </item>
    <item>
      <title>Simple guide of Flexbox in Real Life🔥</title>
      <dc:creator>Kevin Coto🚀💡</dc:creator>
      <pubDate>Mon, 17 May 2021 23:15:40 +0000</pubDate>
      <link>https://dev.to/kevincoto/simple-guide-of-flexbox-in-real-life-3588</link>
      <guid>https://dev.to/kevincoto/simple-guide-of-flexbox-in-real-life-3588</guid>
      <description>&lt;p&gt;Flexbox is an interesting way to make layout At least better -as I see- compared to float's and other techniques.&lt;/p&gt;

&lt;p&gt;So, in this article I'll explain how to use &lt;strong&gt;flexbox in real life&lt;/strong&gt;🔥&lt;/p&gt;

&lt;h2&gt;The first action&lt;/h2&gt;

&lt;p&gt;The first step is writing &lt;code&gt;display:flex&lt;/code&gt; in the father container, then you should write some other lines of code using properties like &lt;code&gt;flex-direction&lt;/code&gt; and others that I tell you about next.&lt;/p&gt;

&lt;h2&gt;Flex-Direction is so basic but it's important&lt;/h2&gt;

&lt;p&gt;This properti sets the direction in which our child elements are shown. We have these:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;row&lt;/code&gt;: this value order our child elements in rows from left to right &lt;br&gt;
&lt;code&gt;row-reverse&lt;/code&gt;: this value order our child elements in rows from right to left &lt;br&gt;
&lt;code&gt;column&lt;/code&gt;: this value order our child elements in rows from up to down &lt;br&gt;
&lt;code&gt;column-reverse&lt;/code&gt;: this value order our child elements in rows from down to top&lt;/p&gt;

&lt;h3&gt;Small mention to the &lt;code&gt;order&lt;/code&gt; property😼&lt;/h3&gt;

&lt;p&gt;So, this property is useful to order our child item through numbers ID but I've never used this property, ordering your elements correctly in the HTML is's enough.&lt;/p&gt;

&lt;h2&gt;The &lt;code&gt;grow&lt;/code&gt; property, this is really important &lt;/h2&gt;

&lt;p&gt;Besides being important, this property it's so useful in the Real Life(☞ﾟヮﾟ)☞&lt;/p&gt;

&lt;p&gt;With this property we can establish the size of our child items so easy, assigning numerical values and the elements can shrink or grow according to the highest or lowest value, lowest to shrink, highest to grow.&lt;/p&gt;

&lt;p&gt;A taste of the flexibility of flexbox🤖&lt;/p&gt;

&lt;p&gt;Early PD:In this article I write about the most used properties used in Real Life if I forget any, let me know in the comments.&lt;/p&gt;

&lt;h2&gt;The King of Flexbox:&lt;code&gt;justify-content&lt;/code&gt;🤴🏽&lt;/h2&gt;

&lt;p&gt;So, let's talk about important things, this property is the King and father of the other properties, it's so important and attractive that for me it's the best property in Flexbox.&lt;/p&gt;

&lt;p&gt;I'm going to explain to yoy how this property works, thorugh two images:&lt;br&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%2Forzj370uein1siuuxdct.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%2Forzj370uein1siuuxdct.png" alt="alt text" width="800" height="265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;br&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%2Fn0e90umzu4iow8s6zd9j.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%2Fn0e90umzu4iow8s6zd9j.png" alt="alt text" width="800" height="251"&gt;&lt;/a&gt;&lt;br&gt;
PD: Sorry, this article is just part #1, in two days I'm going to publish the second part of Flexbox in Real Life🔥📚&lt;/p&gt;

</description>
      <category>flexbox</category>
    </item>
  </channel>
</rss>
