pageCount.js

    0

    0

    The code uses the Math.min() function to find the smallest of two numbers. The function first divides the numbers by 2 to get the front and back flips. It then calculates the minimum of these two flips.

    function pageCount(n, p) {
      var frontFlip = Math.floor(p/2);
      var backFlip = Math.floor((n/2)-frontFlip);
      
      var result = Math.min(frontFlip, backFlip);
      return result;
    
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.