A simple and fun web application built by Ayush Jha that displays random dad jokes to brighten your day.
(Note: You can replace screenshot.png with an actual screenshot of your project.)
This project is a "Don't Laugh Challenge" featuring a curated list of dad jokes. It presents a random joke on the screen, and with the click of a button, you can fetch a new one. It's a fantastic beginner project that demonstrates how to fetch data from an external API and manipulate the DOM with JavaScript.
The user interface is clean, simple, and responsive, ensuring a good experience on different screen sizes.
- Displays a random joke on page load.
- Fetches and displays a new joke when the "Get Another Joke" button is clicked.
- Clean, centered, and responsive user interface.
- A fun footer credit to the creator.
This project is built using fundamental web technologies:
- HTML5: For the structure and content of the web page.
- CSS3: For styling the user interface, including layout, colors, and fonts.
- JavaScript (ES6+): For the application's logic, including fetching jokes from an API and updating the content on the page.
The application's logic resides in script.js.
- When the page loads, or when the "Get Another Joke" button is clicked, a JavaScript function is triggered.
- This function uses the
fetchAPI to make aGETrequest to the icanhazdadjoke API. - The request headers are set to
Accept: 'application/json'to ensure the API returns the joke in JSON format. - Once the response is received, the JSON data is parsed to extract the joke text.
- Finally, the joke text is inserted into the HTML element with the ID
joke, replacing the old joke.
To run this project locally, simply follow these steps:
- Clone the repository or download the files.
- Open the
index.htmlfile in your web browser.
That's it! You can now enjoy an endless stream of dad jokes.
Made with ❤️ by Ayush Jha.
