Generate Random Point in a Circle LeetCode solution in JavaScript
1var Solution = function (radius, x_center, y_center) {2this.radius = radius;3this.x_center = x_center;4this.y_center = y_center;5};67Solution.prototype.randPoint = function () {8let r = this.radius * Math.sqrt(Math.random());9let theta = Math.random() * 2 * Math.PI;10let x = this.x_center + r * Math.cos(theta);11let y = this.y_center + r * Math.sin(theta);12return [x, y];13};