API Docs for: 1.0.0
Show:

Program Class

Defined in: calculator_v2.js:196
Module: Calculator

The model for the rpn calculator: creates a push-pop stack object to hold and process digits and operators.

Constructor

Program

() Void

Returns:

Void:

Item Index

Properties

Methods

clear

() Void

Clears the stack by setting its length to zero.

Returns:

Void:

parseStack

(
  • stack
)
Float

Recursive function to parse stack and perform all operations.

Parameters:

  • stack Array

    must be a copy of this.stack

Returns:

Float:

performOperation

(
  • o
)
Float

Function called when an operator key (e.g. + or /) is pressed.

Parameters:

  • o Object

    may be a Number or String

Returns:

Float:

pop

() Mixed

Fetches the top item off the stack.

Returns:

Mixed: Number | String

push

() Void

Put an item onto the top of the stack.

Returns:

Void:

runProgram

() Float

Calls parseStack, which calculates the stack.

Returns:

Float:

undo

() Void

Removes the last-entered operand from the stack (pops and discards it).

Returns:

Void:

Properties

stack

Array

A stack to store the input values and functions.