Problem Statement

You are tasked with creating a utility function computeAmount that allows chaining multiple calls to represent large monetary values in Indian numbering system units — crores, lacs, and thousands.

Each chained method should return the same object to allow method chaining, and finally, a value() method should return the computed total in rupees.

Requirements

  1. Support the following chained methods:
    • .crore(val) → adds val * 10,000,000
    • .lacs(val) → adds val * 100,000
    • .thousand(val) → adds val * 1,000
  2. Allow multiple chained calls in any order.
  3. Calling .value() should return the final computed total.
  4. Each intermediate call must return the same chainable object.

Example

const total = computeAmount()
.lacs(15)
.crore(5)
.crore(2)
.lacs(20)
.thousand(45)
.crore(7)
.value();

console.log(total); // 1420045000


Explanation:

15 lacs = 1,500,000
5 crore = 50,000,000
2 crore = 20,000,000
20 lacs = 2,000,000
45 thousand = 45,000
7 crore = 70,000,000
-----------------------
Total = 1420045000

Constraints

  • Input values (val) will always be non-negative numbers.
  • Chained methods can be called in any order.