This JavaScript function will calculate the Golden Ratio of a given value.
function calculateGoldenRatio(width) {
if (!width) {
return {};
}
return {
width: width,
right: Math.round(width / 1.61803),
total: Math.round(width * 1.61803),
left: width - Math.round(width / 1.61803)
};
}
var gr = calculateGoldenRatio(920);
console.log(gr.left); // 351
console.log(gr.right); // 569
console.log(gr.total); // 1489
console.log(gr.width); // 920