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.
To run this app locally, you'll need to have Node.js and npm installed. Once you have those, follow these steps:
- Clone this repository to your local machine.
- Navigate to the project directory in your terminal.
- Run
npm install
to install the project dependencies. - Run
npm run dev
to start the development server.
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.
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.