mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-12-19 06:58:15 +08:00
npx standard --fix
This commit is contained in:
20
maths/abs.js
20
maths/abs.js
@@ -11,16 +11,16 @@
|
||||
https://en.wikipedia.org/wiki/Absolute_value
|
||||
*/
|
||||
|
||||
function abs_val(num) {
|
||||
// Find absolute value of `num`.
|
||||
"use strict";
|
||||
if (num < 0) {
|
||||
return -num
|
||||
}
|
||||
// Executes if condition is not met.
|
||||
return num
|
||||
function abs_val (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 " + abs_val(-34));
|
||||
console.log("The absolute value of 34 is " + abs_val(34));
|
||||
console.log('The absolute value of -34 is ' + abs_val(-34))
|
||||
console.log('The absolute value of 34 is ' + abs_val(34))
|
||||
|
||||
Reference in New Issue
Block a user