aaronpo97 / promise-demo

Home Page:https://promise-demo.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Color Changing App

This is a simple web app that demonstrates three different ways to change the background color of a webpage using JavaScript: using callbacks, Promises, and async/await.

Installation

To run this app locally, you'll need to have Node.js and npm installed. Once you have those, follow these steps:

  1. Clone this repository to your local machine.
  2. Navigate to the project directory in your terminal.
  3. Run npm install to install the project dependencies.
  4. Run npm run dev to start the development server.

Usage

Once the app is running, you should see three buttons on the page labeled "Callbacks", "Promises", and "async/await". Clicking each button will trigger a different color-changing function that demonstrates that approach.

Code Structure

The code for this app is divided into several files:

  • index.html - The main HTML file for the app.
  • main.js - The entry point for the JavaScript code. Imports the color-changing functions and sets up event listeners on the buttons.
  • usingCallbacks.js - Defines the color-changing function using callbacks.
  • usingPromises.js - Defines the color-changing function using Promises.
  • usingAsyncAwait.js - Defines the color-changing function using async/await.

About

https://promise-demo.vercel.app


Languages

Language:JavaScript 84.7%Language:HTML 10.7%Language:CSS 4.6%