Files
week2-day5/README.md
2026-04-07 17:54:45 +00:00

95 lines
1.8 KiB
Markdown
Raw Permalink 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 5 Smart Analyzer v3 (Advanced)
Project Overview
This project is an advanced version of the Number Analyzer. It uses **arrays, objects, functions, and sorting** to generate structured data and display it in a **dynamic HTML table**.
Features
* Takes user input
* Generates numbers from 1 to input
* Identifies:
* Even / Odd
* Prime numbers
* Calculates:
* Square
* Cube
* Displays output in **table format**
* Supports **sorting (Ascending / Descending)**
* Shows summary counts
Tech Stack
* HTML5
* CSS3
* JavaScript (Vanilla JS)
How It Works
1. User enters a number
2. Selects sorting order (Ascending / Descending)
3. Clicks **Analyze**
4. Application flow:
* `generateData()` → creates array of objects
* `sortData()` → sorts data
* `renderTable()` → displays table
5. Summary is shown below table
Data Structure Used
Each number is stored as an object:
{
number: 5,
type: "Odd",
prime: true,
square: 25,
cube: 125
}
Key Concepts Used
* Arrays & Objects
* Array methods (`push`, `forEach`, `sort`)
* Functions & modular code
* DOM manipulation
* Template literals
* Conditional logic
* Prime number optimization (√n)
Output Example
| Number | Type | Prime | Square | Cube |
| ------ | ---- | ----- | ------ | ---- |
| 1 | Odd | No | 1 | 1 |
| 2 | Even | Yes | 4 | 8 |
| 3 | Odd | Yes | 9 | 27 |
Summary:
* Total Even: 1
* Total Odd: 2
* Total Prime: 2
Future Improvements
* Add search/filter functionality
* Highlight prime numbers with color
* Export data (CSV / Excel)
* Add pagination for large inputs
Learning Outcome
* Structuring data using objects
* Transforming data using arrays
* Rendering dynamic UI components
* Implementing sorting logic
* Writing modular and scalable JavaScript