Computer >> Computer tutorials >  >> Programming >> Javascript

How can I specify the base for Math.log() in JavaScript?


To specify the base for Math.log(), change the base by dividing by log(10).

Example

You can try to run the following code to implement adding a base for Math.log() −

<html>
   <head>
      <title>JavaScript Math log() Method</title>
   </head>
   <body>
      <script>
         var value = Math.log(100)/Math.LN10;
         document.write("Value : " + value );
      </script>
   </body>
</html>