xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to get PI (π) value in JavaScript
JavaScript Online Editor
Run Code
More JavaScript Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Get π (PI) Value in JavaScript</title> <!--Script tag is added to write JavaScript code inside it--> <script> let piValue = Math.PI; //Math.PI is used to get π (pi) value let piValue_2 = piValue.toFixed(2); //fixed to 2 digits after the decimal point function myFunction() { // backticks `` is used for the template string document.getElementById("myResult").innerHTML = `The value of π (pi) is ${piValue_2}.`; } </script> </head> <body> <h1>How to Get π (PI) Value in JavaScript?</h1> <button onclick="myFunction()">Click here to see result</button> <p id="myResult"></p> </body> </html>