js use switch case to determine object value code example
Example 1: javascript switch assignment
var price = (function(color) {
switch(color) {
case 'red':
return 10;
case 'blue':
return 20;
default:
return 30;
}
})('blue');
console.log(price); // Will print 20
Example 2: typescript inline switch
{(() => {
switch (header) {
case "Name": return entry.name;
case "Type": return entry.type;
default: return entry.name;
}
})()}