Javascript/Math: editing file name

This commit is contained in:
itsvinayak
2020-05-06 18:30:19 +05:30
parent ba75297f72
commit 75f6888019
24 changed files with 0 additions and 0 deletions

26
Maths/Abs.js Normal file
View File

@@ -0,0 +1,26 @@
/*
author: PatOnTheBack
license: GPL-3.0 or later
Modified from:
https://github.com/TheAlgorithms/Python/blob/master/maths/abs.py
This script will find the absolute value of a number.
More about absolute values:
https://en.wikipedia.org/wiki/Absolute_value
*/
function absVal (num) {
// Find absolute value of `num`.
'use strict'
if (num < 0) {
return -num
}
// Executes if condition is not met.
return num
}
// Run `abs` function to find absolute value of two numbers.
console.log('The absolute value of -34 is ' + absVal(-34))
console.log('The absolute value of 34 is ' + absVal(34))