Just a project to abstract math functions from basic to I-don't-know-where.
add(x, y)
Where x and y are numbers
A number corresponding to the answer
add(1,2)
// 3
add(8,-2)
// 6
sum(...addends)
Where addends is a numeric array of any size
A number corresponding to the sum of all addends
sum(1,2,3,4)
// 10
sum(1, -8, 10, 15, -17)
// 1
sub(x, y)
Where x and y are numbers
A number corresponding to the answer
sub(1,2)
// -1
sub(-8,-2)
// -6
diff(...parts)
Where parts is a numeric array of any size
A number corresponding to the difference of all parts, from left to right
diff(1,2,3,4)
// -8
diff(1, -8, 10, 15, -17)
// 1
multiply(x, y)
Where x and y are numbers
A number corresponding to the answer
multiply(1,2)
// 2
multiply(2,-2)
// 4
product(...parts)
Where parts is a numeric array of any size
A number corresponding to the multiplication of all parts
product(1,2,3,4)
// 24
product(1, -8, 10, 15, -17)
// 20400
divide(x, y)
Where x and y are numbers
A number corresponding to the answer
divide(4,2)
// 2
divide(15,3)
// 5
quotient(...parts)
Where parts is a numeric array of any size
A number corresponding to the division of all parts, from left to right
quotient(1,2,3,4)
// 0,041666667
quotient(1, -8, 10, 15, -17)
// 0,00004902
isOdd(x)
Where x is a number
Boolean value indicating that number is odd or not
isOdd(5)
// true
isOdd(2)
// false
isEven(x)
Where x is a number
Boolean value indicating that number as Even or not
isEven(5)
// false
isEven(2)
// true
getRelevantPossibleDivisors(x)
Where x is a number
An array of every relevant divisors, for prime calculation, for x. In other words, it will return an array of integers from 2 until √x
getRelevantPossibleDivisors(9)
// [2,3]
getRelevantPossibleDivisors(8)
// [2]
isPrime(x)
Where x is a number
Boolean indicator about x primality
isPrime(7)
// true
isPrime(9)
// false
bulkFunction(list, fn, initialValue)
Where list is an array, fn a function, and initialValue a mixed type
Return the result of a reduce method applied to your list with your function. Using initialValue to begin reducing.
bulkFunction([1,2], (acc, item) => acc + item, 0)
// 3
getRandomPositiveNumber(limit)
Where limit is an integer. Default value for limit is 10.
Return a random number with max value set as parameter.
getRandomPositiveNumber()
getRandomNegativeNumber(limit)
Where limit is an integer. Default value for limit is -10.
Return a random number with max value set as parameter.
getRandomNegativeNumber()
getRandomPositiveArray(limit, size)
Where limit and size are integers. Default value for limit is 10, and for size is 4.
Return an array, with required size, where every content item is a positive number lower than limit.
getRandomPositiveArray()
getRandomNegativeArray(limit, size)
Where limit and size are integers. Default value for limit is -10, and for size is 4.
Return an array, with required size, where every content item is a negative number lower than limit.
getRandomNegativeArray()
getRandomMixedArray(limit, size)
Where limit and size are integers. Default value for limit is -10/10, and for size is 4.
Return an array, with required size, where every content item is an any signal number lower than limit.
getRandomMixedArray()
generateIntegerArray(initialValue, finalValue)
Where initialValue and finalValue are integers. Default value for initialValue is 0, and for finalValue is 1.
Return an array of integers, beggining on initialValue and finishing on finalValue
generateIntegerArray()
// [0-1]
generateIntegerArray(5,9)
// [5,6,7,8,9]
npm test
npm run coverage-text