Open hello-tsai opened 2 years ago
const test = { a: 1, b: 2, c: 3 }
const ObjMap = (obj, fn) => { const keys = Object.keys(obj) for (let i =0 ; i < keys.length; i++) { obj[keys[i]] = fn(obj[keys[i]]) } return obj } console.log(ObjMap(test, item => item += 1))
const test = { a: 1, b: 2, c: 3 }
const ObjMap = (obj, fn) => { const keys = Object.keys(obj) for (let i =0 ; i < keys.length; i++) { obj[keys[i]] = fn(obj[keys[i]]) } return obj } console.log(ObjMap(test, item => item += 1))