1.0.3-readme • Published 2 years ago
@berriz44/mathext v1.0.3-readme
mathext
mathext is an extension of the math interface in JavaScript.
how to install:
npm install @berriz44/mathextusage:
const MathExt = require('@berriz44/mathext')items
MathExt.numberRow: number | string | Array<number>
description:
makes a row of numbers
arguments:
- end: number| to what number should it count
- start: number| what number should it start with. defaults to 1.
- step: number| how much to increment each number. defaults to 1. affected by- startand- end.
- datatype: number | string | Array<any>| can be any number, array or string. defaults to array. determines the return type of the function.
returns:
a number, string, or Array<number> representing a row of numbers
examples:
MathExt.numberRow(10, 1)
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
typeof MathExt.numberRow(10, 1)
/// Array<number>MathExt.numberRow(11, 1, 2)
// [1, 3, 5, 7, 9, 11]MathExt.numberRow(10, 1, 1, "")
// "12345678910"
typeof MathExt.numberRow(10, 1, 1, "")
// 'string'MathExt.numberRow(10, 1, 1, 0)
// 12345678910
typeof MathExt.numberRow(10, 1, 1, 0)
// 'number'MathExt.isPositive: boolean
description:
says if a number is positive or not
arguments:
i: number | which number to know whether it is positive or negative
returns:
true if i is positive, false if i is negative
examples:
MathExt.isPositive(77)
// trueMathExt.isPositive(-24)
// falseexamples:
MathExt.infinity: number
description:
returns infinity or negative infinity based on a parameter
arguments:
side: number | any number. affects the return value.
returns:
infinity if side is a positive number and -infinity if side is a negative number
examples:
MathExt.infinity(1)
// InfinityMathExt.infinity(-1)
// -InfinityMathExt.turnStringArrayToNumberArray: Array<number>
description:
turns a string array into a number array
arguments:
arr: Array<string> | the array to convert
returns:
an Array<number> with numbers from the arr parameter
examples:
MathExt.turnStringArrayToNumberArray(["10", "4", "9", "fffg"])
// [10, 4, 9, NaN]