This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clone(object) { | |
let newObject = {} | |
for (let prop in object) { | |
newObject[prop] = (typeof object[prop] !== 'object') ? object[prop] : clone(object[prop]) | |
} | |
return newObject; |