Created
May 2, 2020 00:01
-
-
Save jayjariwala/1e436d93cfaf9bd2723880c835a6aa9b 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
function createCircle(r) { | |
let radius = r; | |
this.draw = function() { | |
console.log("draw the cirlce"); | |
}; | |
this.getRadius = function() { | |
return radius; | |
}; | |
this.setRadius = function(val) { | |
if (val <= 0) { | |
throw Error("Number is not valid"); | |
} | |
radius = val; | |
return radius; | |
}; | |
} | |
const circle = new createCircle(10); | |
console.log(circle.getRadius()); | |
const newRadius = circle.setRadius(-10); | |
console.log(newRadius); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment