</>
{...}
function()
const dev =
async/await
Coding Blog Logo

<Hunting Coder />

#JavaScript#React#NextJS#WebDev#Algorithms#DataStructures

Discover the latest in coding and development. From algorithms to frameworks, your daily dose of programming insights.

hunting-coder@terminal
$_

Our Tech Stack

JavaScript
React
Next.js
Tailwind CSS
MongoDB
Node.js
Express
Cloud

Code Snippets

React Hooks
import { useState, useEffect } from 'react';

function useFetch(url) {
  const [data, setData] = useState(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch(url);
        const json = await response.json();
        setData(json);
        setLoading(false);
      } catch (error) {
        setError(error);
        setLoading(false);
      }
    };

    fetchData();
  }, [url]);

  return { data, loading, error };
}
Algorithm
// Binary Search Algorithm
function binarySearch(arr, target) {
  let left = 0;
  let right = arr.length - 1;
  
  while (left <= right) {
    const mid = Math.floor((left + right) / 2);
    
    if (arr[mid] === target) {
      return mid;
    } else if (arr[mid] < target) {
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }
  
  return -1; // Target not found
}

Coding Activity

git commit -m "Daily coding progress"

Latest Blogs