File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 1- /*
2- author: PatOnTheBack
3- license: GPL-3.0 or later
4-
5- Modified from:
6- https://github.com/TheAlgorithms/Python/blob/master/maths/abs.py
7-
8- This script will find the absolute value of a number.
9-
10- More about absolute values:
11- https://en.wikipedia.org/wiki/Absolute_value
12- */
1+ /**
2+ * @function absVal
3+ * @description This script will find the absolute value of a number.
4+ * @param {Integer } num - The input integer
5+ * @return {Integer } - Absolute number of num.
6+ * @see [Absolute_value](https://en.wikipedia.org/wiki/Absolute_value)
7+ * @example absVal(-10) = 10
8+ * @example absVal(50) = 50
9+ * @example absVal(0) = 0
10+ */
1311
1412const absVal = ( num ) => {
1513 // Find absolute value of `num`.
Original file line number Diff line number Diff line change @@ -10,4 +10,9 @@ describe('absVal', () => {
1010 const absOfPositiveNumber = absVal ( 50 )
1111 expect ( absOfPositiveNumber ) . toBe ( 50 )
1212 } )
13+
14+ it ( 'should return an absolute value of a zero number' , ( ) => {
15+ const absOfPositiveNumber = absVal ( 0 )
16+ expect ( absOfPositiveNumber ) . toBe ( 0 )
17+ } )
1318} )
You can’t perform that action at this time.
0 commit comments