Skip to content

Instantly share code, notes, and snippets.

function extractNum(str) {
const match = str.match(/\d+/);
return parseInt(match[0], 10);
}
function calcSum(arr) {
const flatArr = arr.flat(2);
let sum = 0;
flatArr.forEach((item) => {
function clone(object) {
let newObject = {}
for (let prop in object) {
newObject[prop] = (typeof object[prop] !== 'object') ? object[prop] : clone(object[prop])
}
return newObject;