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
-
User enters a number
-
Loop runs from 1 to input
-
For each number:
- Even → i % 2 === 0
- Odd → else
- Prime → checked using divisor loop
-
Counters track totals
-
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
Description
Languages
JavaScript
52%
CSS
25.7%
HTML
22.3%