Minimalist Chuck Norris Jokes Fetcher

Published on Thu Mar 20 2025

Written by Nacho Consolani

Chuck Norris Jokes Fetcher App

web development

oop

typescript

local storage

react

Live Demo

GitHub Repository

Project Overview

The Minimalist Chuck Norris Jokes Fetcher is a lightweight web application designed to fetch random Chuck Norris jokes from an external API. It also allows users to save their favorite jokes to a local collection using the browser’s local storage.

This project was built with a focus on simplicity, performance, and user experience. The app is hosted on Vercel and is fully responsive, ensuring a seamless experience across devices.

Key Features

Technical Highlights

Ad-hoc OOP-Oriented State Management

One of the core challenges of this project was implementing a state management system that leverages the browser’s local storage. To achieve this, I designed an Object-Oriented Programming (OOP) approach for managing the jokes collection. Here’s how it works:

Example Code

export class LocalStorageJokeCollection {
  private collection: Joke[] = [];

  constructor(private storageKey: string = "jokes") {
    const storedData = localStorage.getItem(this.storageKey);
    if (storedData) {
      this.collection = JSON.parse(storedData);
    }
  }

  addJoke(joke: Joke) {
    if (!this.collection.find((j) => j.id === joke.id)) {
      this.collection.push(joke);
      this.save();
    }
  }

  removeJoke(jokeId: string) {
    this.collection = this.collection.filter((j) => j.id !== jokeId);
    this.save();
  }

  getJokes(): Joke[] {
    return [...this.collection];
  }

  private save() {
    localStorage.setItem(this.storageKey, JSON.stringify(this.collection));
  }
}

This approach ensures that the jokes collection is always in sync with the local storage while maintaining a clean and testable codebase.

Lessons Learned

Future Improvements

This project was a fun and educational experience, showcasing how modern web technologies can be used to build simple yet powerful applications. Check out the live demo and feel free to explore the GitHub repository for more details.