const clampNumber = (num: number, a: number, b: number) =>
        Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
      

      Typescript language logo
      Clamp number

      Codiga's TypeScript Recipes

      Clamps num within the inclusive range specified by the boundary values a and b.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.