curriculum/challenges/english/blocks/daily-coding-challenges-javascript/697a49e6ff50d756c9b6935e.md
Given a snowboarder's starting stance and a rotation in degrees, determine their landing stance.
"Regular" or "Goofy".For example, given "Regular" and 90, return "Regular". Given "Regular" and 180 degrees, return "Goofy".
getLandingStance("Regular", 90) should return "Regular".
assert.equal(getLandingStance("Regular", 90), "Regular");
getLandingStance("Regular", 180) should return "Goofy".
assert.equal(getLandingStance("Regular", 180), "Goofy");
getLandingStance("Goofy", -270) should return "Regular".
assert.equal(getLandingStance("Goofy", -270), "Regular");
getLandingStance("Regular", 2340) should return "Goofy".
assert.equal(getLandingStance("Regular", 2340), "Goofy");
getLandingStance("Goofy", 2160) should return "Goofy".
assert.equal(getLandingStance("Goofy", 2160), "Goofy");
getLandingStance("Goofy", -540) should return "Regular".
assert.equal(getLandingStance("Goofy", -540), "Regular");
function getLandingStance(startStance, rotation) {
return startStance;
}
function getLandingStance(startStance, rotation) {
const flips = Math.floor(Math.abs(rotation) / 180);
if (flips % 2 === 0) {
return startStance;
} else {
return startStance === "Regular" ? "Goofy" : "Regular";
}
}