Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 1.03 KB

File metadata and controls

41 lines (32 loc) · 1.03 KB

Random Color Generator (JavaScript)

A beginner-friendly JavaScript mini project that dynamically changes the background and text color of elements using random RGB values.

🚀 Features

  • Generates random colors using JavaScript
  • Applies colors to multiple elements
  • Uses DOM manipulation
  • Simple and clean logic

🛠️ Technologies Used

  • HTML
  • CSS
  • JavaScript

📸 How It Works

  • Selects all child elements inside a container
  • Generates random RGB values
  • Applies them as background and text color

🧠 Learning Outcomes

  • Understanding of DOM selection
  • Working with arrays and loops
  • Random number generation
  • Dynamic styling using JavaScript

▶️ How to Run

  1. Download or clone the repository
  2. Open index.html in your browser
  3. Refresh to see new random colors

📌 Example Code

function getRandomColor(){
    let val1 = Math.ceil(Math.random() * 255);
    let val2 = Math.ceil(Math.random() * 255);
    let val3 = Math.ceil(Math.random() * 255);
    return `rgb(${val1}, ${val2}, ${val3})`;
}