Skip to content

ncminh/vibejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppScript Example Project

This project is a simple JavaScript application template designed for learning, experimentation, and demonstration purposes. It provides a minimal setup to help users quickly start working with JavaScript, HTML, and CSS, either as a static web page or with Node.js tooling.

Project Description

The AppScript project demonstrates a basic web application structure using JavaScript and HTML. It includes example files for both main application logic and testing, as well as integration with Bootstrap for styling. The project is suitable for beginners who want to understand how to organize a small web project, or for anyone needing a quick starting point for JavaScript experiments.

Key features:

  • Simple, easy-to-understand file structure
  • Ready-to-use HTML and JavaScript files
  • Bootstrap included for rapid UI prototyping
  • Example test files for learning and experimentation
  • Can be run as a static site or with Node.js/npm scripts

About calculateWithRates

The core of this example is the calculateWithRates function, which demonstrates how to apply progressive rate calculations to an input amount. This is useful for scenarios like tiered billing, tax brackets, or utility pricing.

How it works:

  • The function takes an amount and an optional unit (default 1000).
  • It defines several "slabs" (tiers), each with a capacity and a rate:
    • 0–10×unit: 5%
    • 10×unit–30×unit: 10%

    • 30×unit–60×unit: 20%

    • 60×unit–100×unit: 30%

    • 100×unit: 35%

  • The function allocates the input amount across these slabs, applying the corresponding rate to each portion.
  • For each slab, it calculates:
    • How much of the amount falls into the slab (allocated)
    • The rate for that slab
    • The value (allocated × rate)
  • It returns a breakdown of all slabs used and the total calculated value.

Example:

If you call calculateWithRates(37), the function will:

  • Allocate 10 to the first slab (5%), 27 to the second slab (10%), and none to the higher slabs.
  • Return a breakdown showing how much was charged at each rate, and the total.

This approach is commonly used in real-world pricing models where different portions of a total are charged at different rates.

AppScript Example Project

This is a simple JavaScript project example.

Getting Started

  1. Clone the repository:

    git clone <repository-url>
    cd appscript
  2. Install dependencies:

    npm install
  3. Run the project:

    npm start

    Or open index.html directly in your browser for a static demo.

Project Structure

Notes

License

This project is for demonstration purposes only.

About

Vibecoding JS for POC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published