## 30秒学会 JavaScript 片段 – minN

Returns the `n` minimum elements from the provided array.
If `n` is greater than or equal to the provided array’s length, then return the original array (sorted in ascending order).

Use `Array.prototype.sort()` combined with the spread operator (`...`) to create a shallow clone of the array and sort it in ascending order.
Use `Array.prototype.slice()` to get the specified number of elements.
Omit the second argument, `n`, to get a one-element array.

## 30秒学会 Dart 片段 – intersectionBy

Returns a list of elements that exist in both lists, after applying the provided function to each element of both.

Use `Iterable.toSet()` and `Iterable.map()` to get the unique values in `b` after applying `fn` to them.
Use `Iterable.map()` to apply `fn` to all the values of `a`, `Iterable.toSet()`, `Iterable.where()` and `Iterable.contains()` to keep only the values in the resulting list contained in the unique mapped values of `b`, `Iterable.toList()` to return the appropriate result.

## 30秒学会 JavaScript 片段 – factorial

Calculates the factorial of a number.

Use recursion.
If `n` is less than or equal to `1`, return `1`.
Otherwise, return the product of `n` and the factorial of `n - 1`.
Throws an exception if `n` is a negative number.

## 30秒学会 JavaScript 片段 – initializeArrayWithRange

Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.

Use `Array.from()` to create an array of the desired length, `(end - start + 1)/step`, and a map function to fill it with the desired values in the given range.
You can omit `start` to use a default value of `0`.
You can omit `step` to use a default value of `1`.

## 30秒学会 C# 片段 – IsPowerOfTwo

Returns `true` if the given number is a power of `2`, `false` otherwise.

Use the bitwise binary AND operator (`&`) to determine if `n` is a power of `2`.
Additionally, check that `n` is different from `0`.