curriculum/challenges/english/blocks/daily-coding-challenges-javascript/68c1a929005bf54d342aa8d6.md
For the fifth day of Space Week, you will calculate the "Goldilocks zone" of a star - the region around a star where conditions are "just right" for liquid water to exist.
Given the mass of a star, return an array with the start and end distances of its Goldilocks Zone in Astronomical Units.
To calculate the Goldilocks Zone:
For example, given 1 as a mass, return [0.95, 1.37].
goldilocksZone(1) should return [0.95, 1.37].
assert.deepEqual(goldilocksZone(1), [0.95, 1.37]);
goldilocksZone(0.5) should return [0.28, 0.41].
assert.deepEqual(goldilocksZone(0.5), [0.28, 0.41]);
goldilocksZone(6) should return [21.85, 31.51].
assert.deepEqual(goldilocksZone(6), [21.85, 31.51]);
goldilocksZone(3.7) should return [9.38, 13.52].
assert.deepEqual(goldilocksZone(3.7), [9.38, 13.52]);
goldilocksZone(20) should return [179.69, 259.13].
assert.deepEqual(goldilocksZone(20), [179.69, 259.13]);
function goldilocksZone(mass) {
return mass;
}
function goldilocksZone(mass) {
const luminosity = Math.pow(mass, 3.5);
const start = 0.95 * Math.sqrt(luminosity);
const end = 1.37 * Math.sqrt(luminosity);
return [Number(start.toFixed(2)), Number(end.toFixed(2))];
}