Created
September 5, 2014 21:58
-
-
Save christurnertv/6d70b105157997753593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>JS Arrays</title> | |
</head> | |
<body> | |
<button id="btnAddContact">Add Contact</button> | |
<script> | |
// create a circle object | |
var circle = { | |
radius: 3, | |
getArea: function () { | |
// todo: finish this method | |
// hint: area = pi * radius^2 | |
return Math.PI * Math.pow(this.radius, 2); | |
}, | |
logInfo: function (round) { | |
var area = this.getArea(); | |
if (round) { | |
area = Math.round(area); | |
} | |
console.log('Area of a circle with radius: ' + this.radius + ', is: ' + area); | |
} | |
}; | |
// log info about the circle | |
circle.logInfo(false); | |
circle.logInfo(true); | |
// todo: | |
// Change the radius of the circle to 5. | |
circle.radius = 5; | |
// log info about the circle | |
circle.logInfo(false); | |
circle.logInfo(true); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment