Write a function chooseLift(liftA, liftB, callFloor) that returns which of two lifts goes to a person: the string 'A' or 'B'. A building has two lifts, A and B. The person is on floor callFloor and presses the "up" button.
liftA and liftB are the floors where the lifts stand now.Math.abs(liftA - callFloor).callFloor goes: it moves up anyway, the same way the person wants to go.'A' goes.An if statement with comparison operators is enough.
chooseLift(5, 1, 2)Returns 'B'
chooseLift(0, 4, 2)Returns 'A'
chooseLift(3, 3, 1)Returns 'A'
Asked at Goomo · Source
chooseLift(5, 1, 2)'B'chooseLift(2, 7, 2)'A'chooseLift(3, 3, 1)'A'Hidden tests run on Submit.