Files
week2-day3/README.md
2026-04-07 17:30:43 +00:00

75 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Week 2 Day 3 Number Analyzer
Project Overview
This project is a JavaScript-based web application that analyzes numbers using loops. It identifies whether numbers are **even, odd, and prime**, and provides a summary count.
Features
* Takes user input
* Generates numbers from 1 to input
* Identifies:
* Even numbers
* Odd numbers
* Prime numbers
* Displays total counts
* Dynamic UI update
Tech Stack
* HTML5
* CSS3
* JavaScript (Vanilla JS)
How It Works
1. User enters a number
2. Loop runs from 1 to input
3. For each number:
* Even → i % 2 === 0
* Odd → else
* Prime → checked using divisor loop
4. Counters track totals
5. Output displayed dynamically
Key Concepts Used
* for loops
* Nested loops
* Conditional statements
* Prime number logic
* Counters (frequency counting)
* DOM manipulation
Output Example
Input: 5
1 - Odd
2 - Even | Prime
3 - Odd | Prime
4 - Even
5 - Odd | Prime
Total Even Numbers: 2
Total Odd Numbers: 3
Total Prime Numbers: 3
Future Improvements
* Optimize prime check (√n method)
* Add input validation
* Add reset button
* Highlight primes with color
Learning Outcome
* Understanding of loops and nested loops
* Implementation of mathematical logic
* Real-world problem solving using JavaScript
* Efficient use of counters and conditions