Merge pull request #1370 from augustoscher/add-logarithm-calculator

Adding logarithm calculator for given number in given base
This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-07 19:15:11 +03:00
committed by GitHub

17
snippets/logBase.md Normal file
View File

@ -0,0 +1,17 @@
---
title: logBase
tags: math,beginner
---
Returns 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.
```js
const logBase = (n, base) => Math.log(n) / Math.log(base);
```
```js
logBase(10, 10); // 1
logBase(100, 10); // 2
```