Files
30-seconds-of-code/snippets/logBase.md
Angelos Chalaris 8a6b73bd0c Update covers
2023-02-16 22:24:28 +02:00

432 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Logarithm in specific base math yellow-white-mug-2 2020-10-07T19:14:30+03:00 2020-10-22T20:23:47+03:00

Calculates the logarithm of the given number in the given base.

  • Use Math.log() to get the logarithm from the value and the base and divide them.
const logBase = (n, base) => Math.log(n) / Math.log(base);
logBase(10, 10); // 1
logBase(100, 10); // 2