-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexercise2.js
More file actions
31 lines (23 loc) · 948 Bytes
/
exercise2.js
File metadata and controls
31 lines (23 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* EXERCISE 2
/
/ Directions:
/ Today is 3/14, also known as PI day.
/ Write a function that calculates the area of a circle when given a radius
/ When I call the function calculateArea(radius), the return value will be the area rounded to the closest integer
/
/ Input (arguments) : Number -- i.e. the radius of the circle
/ Output (return) : Number -- i.e. the area of the circle AS AN INTEGER
/
/ Tools and functions you'll probably need to use:
/ 1) Math.PI (it's a PROPERTY of the Math object...similar to the .length of an array or string!)
/ 2) Pick either Math.ceil(n) or Math.floor(n). For this exericse, it doesn't matter if you round up or down.
/ 3) What's the formula for the area of a circle?
*/
function calculateArea(radius) {
var area;
/*
/ CODE HERE
*/
return area;
}
window.calculateArea = calculateArea;