30秒学会 JavaScript 片段 – Pad number
Pads a given number to the specified length. Use String.prototype.padStart() to pad the number to sp...
Pads a given number to the specified length. Use String.prototype.padStart() to pad the number to sp...
A sorted array is useful as long as it can maintain its sorting order. Unfortunately, inserting a ne...
Returns the absolute value of the first number, but the sign of the second. Use Math.sign() to check...
Converts a HSL color tuple to RGB format. Use the HSL to RGB conversion formula to convert to the ap...
Converts a color code to an rgb() or rgba() string if alpha value is provided. Use bitwise right-shi...
JavaScript provides a couple of ways to format numeric values to a given precision. Namely, you can ...
Returns the weighted average of two or more numbers. Use sum() to sum the products of the numbers by...
Calculates the Hamming distance between two values. Use the XOR operator (^) to find the bit differe...
Calculates the sum of the powers of all the numbers from start to end (both inclusive). Use Array.pr...
Generates a list of numbers in the arithmetic progression starting with the given positive integer a...