做猿和做人有趣很重要

函数式编程永远滴神

当年咱在十里八乡,那可是有名的俊后生。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
let slogan = {
    lastSentance: '牛年掘金沸点游',
    nextSentance: '成为大佬不用愁',
    summary: '街溜子'
}
function becomeBoss(slogan, way, action) {
    if (way === 'juejin' && action === 'execute') {
        format(slogan);
    } else {
        console.log('快上掘金!');
    }
}
function format({ lastSentance, nextSentance, summary }) {
    console.log('    ' + summary);
    (lastSentance + nextSentance).split('').forEach((item, index, arr) => {
        if (index < lastSentance.length) {
            console.log(item + '         ' + arr[index + 7] + '\n');
        }
    })
}
becomeBoss(slogan, 'juejin', 'execute');

完!