Apply your knowledge to build something amazing!
:information_source: Info Project Information Difficulty Level: Beginner
Estimated Time: 30-45 minutes
Skills Practiced:
What you'll do: Open the project and familiarize yourself with the interface
DO NOT DELETE the existing files in the template:
ONLY EDIT the necessary files.
Let's create a "Quote of the Day" website with animations!
graph LR
A[Phase 1: Setup] --> B[Phase 2: Find Resources]
B --> C[Phase 3: Code Implementation]
C --> D[Phase 4: Test & Submit]
style A fill:#e1f5fe
style B fill:#ffecb3
style C fill:#c8e6c9
style D fill:#f8bbd0
Phase Breakdown:
Here is the challenge:
<lottie-player>
tag src attribute to any animation link you like.:warning: Common Pitfalls to Avoid
- Don't modify the HTML file - All changes must be done through JavaScript!
- Remember to use escape characters - If your quote contains quotes, use
\"
to escape them- Check your animation link - Make sure you copy the full src URL from LottieFiles
- Script placement matters - Ensure your JavaScript runs after the DOM is loaded
Before moving to find your animation, ensure you:
Search for an animation you like from lottiefiles.com.
tip Pro Tip Choose an animation that matches the mood of your quote! For inspirational quotes, try searching for:
To get the src link of your preferred animation, click on Use this animation in <HTML>
:
You will be directed to the Generated Code page of the animation. The src link is the first row:
:information_source: Info What to Look For The src link should look something like this:
https://lottie.host/...long-string-of-characters...json
Copy the entire URL!
If you have done it correctly, it should look something like this:
Before coding, make sure you have:
Use the .textContent
property to assign a quote to the paragraph:
// Example: Find the element and change its text
document.getElementById('quote').textContent = 'Your new quote here';
To use double quotes in a string, you can write with the escape character \"
:
// Example: A quote that contains quotation marks
const myQuote = "Einstein said, \"Imagination is more important than knowledge.\"";
Use the .setAttribute
method to set the src with the animation link:
// Example: Set an attribute on an element
element.setAttribute('src', 'your-animation-url-here');
tip Best Practice Always test your code step by step! First change the quote, then add the animation. This makes debugging easier.
Having trouble? Here's a debugging checklist:
Quote not appearing?
Animation not loading?
https://
Nothing happens when you run the code?
:warning: Remember The most common mistake is forgetting to save your changes! Always save (Ctrl+S or Cmd+S) before testing.
Rather than write the quote and the author directly in the .text-content
property, let's use an object variable to hold the value of the quote, the author and the link of the animation too.
At the top, create an object variable called myQuote
with 3 properties:
// Structure your object like this:
const myQuote = {
quote: "Your inspiring quote here",
author: "Author Name",
link: "https://lottie.host/your-animation-url.json"
};
Then use the object properties to update your page:
// Example of using object properties
document.getElementById('quote').textContent = myQuote.quote + " - " + myQuote.author;
tip Why Use Objects? Objects help organize related data together. This makes your code cleaner and easier to update - you only need to change values in one place!
Ready for more? Try these extra challenges to level up your project:
Create an array of quote objects and display a random one each time the page loads:
const quotes = [
{ quote: "Quote 1", author: "Author 1", link: "animation1.json" },
{ quote: "Quote 2", author: "Author 2", link: "animation2.json" },
// Add more quotes...
];
Add a button that changes the quote when clicked (you'll need to modify the HTML for this advanced challenge).
Use JavaScript to add CSS classes that create a fade-in effect when the quote appears.
Display different quotes based on the time of day (morning, afternoon, evening).
:information_source: Info Going Beyond These extension challenges require additional JavaScript concepts. Don't worry if they seem difficult - they're meant to inspire you to keep learning!
Before submitting, verify:
:tada: Congratulations! You've built your own Quote of the Day website with animations!
When you have completed your "Quote of the Day" project, submit it using the link below:
tip Before You Submit Make sure to test your webpage before submitting to ensure all required elements are working properly! Share your project with a friend or family member - they'll be impressed by what you've created!
Through this project, you've gained valuable skills in:
Keep coding and creating amazing projects! :rocket: