Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by www.codekitchen.ca #
 
PREVIOUS NEXT
Tagged: #javascript #switch #assignment
ADD COMMENT
Topic
Name
2+3 =