javascript difference between 2 numbers code example Example: js difference between two numbers var difference = function (a, b) { return Math.abs(a - b); }