math.combinations関数の第一引数に総数を、第二引数に取り出す数を渡すと、組み合わせの数が返されます。
<html>
<head>
<script type=text/javascript src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/9.4.4/math.min.js"></script>
</head>
<body>
<script>
var ret1 = math.combinations(5, 3);
console.log(ret1);
var ret2 = math.combinations(3, 1);
console.log(ret2);
</script>
</body>
</html>
リンク
math.js | an extensive math library for JavaScript and Node.js
https://mathjs.org/docs/reference/functions/combinations.html