Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
switch case solution in Clear category for [old] Simple Areas by MaxGraey
function simpleAreas(...args) {
switch (args.length) {
case 1: return 0.25 * Math.PI * args[0] ** 2
case 2: return args[0] * args[1]
case 3: {
const a = args[0], b = args[1], c = args[2], p = (a + b + c) / 2
return Math.sqrt(p * (p - a) * (p - b) * (p - c))
}
}
return 0
}
May 14, 2019