Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function areaOfCircle(radius) {
- this.radius = radius;
- this.area = function() {
- return Math.PI * (radius * radius);
- }
- }
- /* calling the function passing in a number for the radius */
- areaOfCircle(2);
- if (radius != null || radius != undefined){
- console.log('\nThe area of a circle is: ' + area() +
- '\nAlso the area of said circle rounded to two decimal points is: ' + area().toFixed(2));
- }
- else if (radius == null || radius == undefined) {
- console.log('\nError: null or undefined variable in the place of radius variable.\n');
- }
- /* calling the function passing in null for the radius */
- areaOfCircle(null);
- if (radius != null || radius != undefined){
- console.log('\nThe area of a circle is: ' + area() +
- '\nAlso the area of said circle rounded to two decimal points is: ' + area().toFixed(2));
- }
- else if (radius == null || radius == undefined) {
- console.log('\nError: null or undefined variable in the place of radius variable.\n');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement