About business, WHAT I want to say is that the most important thing for an algorithm is if else judgment. However, if else is used too much, people will easily become dizzy, so they want to use the strategic mode to solve the problem. Here I remind myself to use the strategic mode more in the future
const newVal = { value: 1 }
const oldVal = { value: 2 }
const dic = {
'empty': undefined.'Quantity management': 1.'Batch Management': 2.'Product Management': 3
}
switch(oldVal.value + '= >' + newVal.value) {
case dic['empty'] + '= >' + dic['Quantity management'] :console.log(1)
break
case dic['empty'] + '= >' + dic['Batch Management'] :console.log(2)
break
case dic['empty'] + '= >' + dic['Product Management'] :console.log(3)
break
case dic['Quantity management'] + '= >' + dic['Batch Management'] :console.log(4)
break
case dic['Quantity management'] + '= >' + dic['Product Management'] :console.log(5)
break
case dic['Batch Management'] + '= >' + dic['Quantity management'] :console.log(6)
break
case dic['Batch Management'] + '= >' + dic['Product Management'] :console.log(7)
break
case dic['Product Management'] + '= >' + dic['Quantity management'] :console.log(8)
break
case dic['Product Management'] + '= >' + dic['Batch Management'] :console.log(9)
break
default:
console.log('Something unexpected happened! ')}Copy the code