Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Robin robinjl

🎯
Focusing
  • Jilin, China
View GitHub Profile
View recursive.js
// 1*2*3*...100
function recrusive(num){
if(num === 1){
return num;
}else{
return num*recrusive(num-1)
}
}
// 菜单递归 后端返回递归结构,前端更换键名 例如 url -> path
View group_by_property.js
// 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) {
@robinjl
robinjl / generate_random_color.js
Created Nov 27, 2019
generate random color from stackoverflow
View generate_random_color.js
function getRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}