The Math log() static method returns the natural logarithm (base e) of a number.
function getBaseLog(x, y) {
return Math.log(y) / Math.log(x);
}
// 2 x 2 x 2 = 8
console.log(getBaseLog(2, 8));
// 3
// 5 x 5 x 5 x 5 = 625
console.log(getBaseLog(5, 625));
// 4