Al Gee Braa

by Sam Fereday

JavaScript

/// Makes a massive assumption that 'x' is the first value each time.
function simpleAlgebra(left, right)
{

		// Balance either side
		var l = left - left,
    r = right - left;
    
    // Can't get any simpler, so return the difference
		return Math.abs(l - r);

}

var leftHand = 5,
result = 12;

console.log('X is ' + simpleAlgebra(leftHand, result) + '.');