Skip to content

Instantly share code, notes, and snippets.

@Chryus
Created January 21, 2014 02:55
Show Gist options
  • Save Chryus/8533713 to your computer and use it in GitHub Desktop.
Save Chryus/8533713 to your computer and use it in GitHub Desktop.
absolute value function in JavaScript
function absolute(num) {
if (num < 0) {
return -num;
} else {
return num;
}
}
console.log(absolute(-10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment