Skip to content
loading...

re: Daily Challenge #152 - Strongest Number in an Interval VIEW POST

FULL DISCUSSION
 
const calcMaxStrength = (numbers) => {
  const divider = 2;

  const isOdd = number => number % 2 === 0;

  const calcStrength = (dividend, strength = 0) => {
    if (isOdd(dividend)) {
      return calcStrength(dividend / divider, strength += 1);
    }

    return strength;
  };

  return Math.max(...numbers.map(number => calcStrength(number)));
};

console.log(calcMaxStrength([48, 56])); // 4
console.log(calcMaxStrength([129, 193])); // 0
code of conduct - report abuse