Skip to content

Instantly share code, notes, and snippets.

@christurnertv
Created September 5, 2014 21:58
Show Gist options
  • Save christurnertv/6d70b105157997753593 to your computer and use it in GitHub Desktop.
Save christurnertv/6d70b105157997753593 to your computer and use it in GitHub Desktop.
<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