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
// 1*2*3*...100 | |
function recrusive(num){ | |
if(num === 1){ | |
return num; | |
}else{ | |
return num*recrusive(num-1) | |
} | |
} | |
// 菜单递归 后端返回递归结构,前端更换键名 例如 url -> path |
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
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce | |
let people = [ | |
{ name: 'Alice', age: 21 }, | |
{ name: 'Max', age: 20 }, | |
{ name: 'Jane', age: 20 } | |
]; | |
function groupBy(objectArray, property) { | |
return objectArray.reduce(function (acc, obj) { |
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 getRandomColor() { | |
const letters = '0123456789ABCDEF'; | |
let color = '#'; | |
for (let i = 0; i < 6; i++) { | |
color += letters[Math.floor(Math.random() * 16)]; | |
} | |
return color; | |
} |