Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. function areaOfCircle(radius) {
  2. this.radius = radius;
  3. this.area = function() {
  4. return Math.PI * (radius * radius);
  5. }
  6. }
  7.  
  8. /* calling the function passing in a number for the radius */
  9. areaOfCircle(2);
  10. if (radius != null || radius != undefined){
  11. console.log('\nThe area of a circle is: ' + area() +
  12. '\nAlso the area of said circle rounded to two decimal points is: ' + area().toFixed(2));
  13. }
  14. else if (radius == null || radius == undefined) {
  15. console.log('\nError: null or undefined variable in the place of radius variable.\n');
  16. }
  17.  
  18. /* calling the function passing in null for the radius */
  19. areaOfCircle(null);
  20. if (radius != null || radius != undefined){
  21. console.log('\nThe area of a circle is: ' + area() +
  22. '\nAlso the area of said circle rounded to two decimal points is: ' + area().toFixed(2));
  23. }
  24. else if (radius == null || radius == undefined) {
  25. console.log('\nError: null or undefined variable in the place of radius variable.\n');
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement