Description | Regular Expression |
---|---|
Any digit | \d |
Any non-digit | \D |
Good interactive tutorial on Regex.
var state = "2x10";
var pattern = /\d+/g;
var result = state.match(pattern);
// result equals ['2', '10']
Spread operator is used to unpack an array an give the elements as parameters to a method. It is useful for things such as giving an array to the Math.max
method to determine the element with the maximum value in the array.
function getSecondLargest(nums) {
let uniq = [...new Set(nums)]
let index = uniq.indexOf(Math.max(...uniq))
uniq.splice(index, 1)
return Math.max(...uniq)
}
https://flaviocopes.com/fetch-api/
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then