The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.
Math.PI
Besides functions
Math
offers some mathematical constants.
Math.PI
gives π (roughly 3.14) and Math.E
gives Euler's number e (roughly 2.71).Exercise
Write a function
Example:
area
that calculates the area of a circle.
The function is given the radius of the circle.Example:
area(1)
should return π
and area(2)
should return 4 * π
.
+ Hint
function area(r) {
return Math.PI ... ;
}
+ Solution
function area(r) {
return Math.PI * r * r;
}