Skip to content

Commit

Permalink
0727learn
Browse files Browse the repository at this point in the history
  • Loading branch information
mogu authored and mogu committed Jul 28, 2020
1 parent 64d5dcd commit 115f42f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 设计模式/策略模式.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const strategy = {
S(salary) {
return salary * 4
},
A(salary) {
return salary * 3
},
B(salary) {
return salary * 2
}
}

const calculate = (leavl, salary) => {
return strategy[leavl](salary)
}



const S = (salary) => {
return salary * 4
}

const A = (salary) => {
return salary * 3
}

const B = () => {
return salary * 2
}

const calculate2 = (func, salary) => {
return func(salary)
}

console.log(calculate2(A, 10000))

0 comments on commit 115f42f

Please sign in to comment.