Are Equally Strong
Call two arms equally strong if the heaviest weights they each are able to lift are equal.
Call two people equally strong if their strongest arms are equally strong (the strongest arm can be both the right and the left), and so are their weakest arms.
Given your and your friend’s arms’ lifting capabilities find out if you two are equally strong.
Example
console.log(areEquallyStrong(10, 15, 15, 10)) true
console.log(areEquallyStrong(15, 10, 15, 10)) true
console.log(areEquallyStrong(15, 10, 15, 9)) false
function areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) {
const yourWeakest = yourLeft <= yourRight ? yourLeft : yourRight;
const yourStrongest = yourLeft >= yourRight ? yourLeft : yourRight;
const friendsWeakest = yourLeft <= yourRight ? yourLeft : yourRight;
const friendsStrongest = yourLeft >= yourRight ? yourLeft : yourRight;
return (yourStrongest === friendsStrongest && yourWeakest === friendsWeakest);
}
console.log(areEquallyStrong(10, 15, 15, 10)) true
console.log(areEquallyStrong(15, 10, 15, 10)) true
console.log(areEquallyStrong(15, 10, 15, 9)) false
We create function called areEquallyStrong with parameters yourLeft, yourRight, friendsLeft, friendsRight
We create four (4) variables
- yourWeakest = yourLeft <= yourRight ? yourLeft : yourRight
- yourStrongest = yourLeft >= yourRight ? yourLeft : yourRight;
- friendsWeakest = yourLeft <= yourRight ? yourLeft : yourRight;
- friendsStrongest = yourLeft >= yourRight ? yourLeft : yourRight;
In the end we *return (yourStrongest* === friendsStrongest && yourWeakest === friendsWeakest)