My attempt to create a function that returns an absolute value of a number. I created an if else statement. If the argument is greater than 0, you return the value. Otherwise, multiply the number with -1 and return that value.
function absolute (a) {
if (a > 0) {
return a;
}
else {
a = -1*a;
return a;
}
}
No comments:
Post a Comment