Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Replacing If Else Chains with Switch

switch (val) {
  case "bob":
    answer = "Marley";
    break;
  case 42:
    answer = "The Answer";
    break;
  case 1:
    answer = "There is no #1";
    break;
  case 99:
    answer = "Missed me by this much!";
    break;
  case 7:
    answer = "Ate Nine";
    break;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: check if element is displayed jsavascript 
Javascript :: exitBeforeEnter not working 
Javascript :: self excuting arrow function 
Javascript :: login_page-jwt-auth-using-react-and-flask 
Javascript :: how to say "and not" in javascript 
Javascript :: js particles without plugin 
Javascript :: for loop remove duplicates javascript 
Javascript :: child to perent data transfer in angular 
Javascript :: Old Syntax of Router Switch 
Javascript :: To enable server-to-server and REST tools like Postman to access our API - 
Javascript :: how to import images from public folder in react js 
Javascript :: GLTF position three.js 
Javascript :: convert todays date to json datetime 
Javascript :: how to difference of arrey object 
Javascript :: Ghost-Blog Maria DB Issue 
Javascript :: Tow sums 
Javascript :: Star Wars Celebration 
Javascript :: video link on videojs 
Javascript :: Will Yield function Model 
Javascript :: jqxAngular 
Javascript :: angular auth guard @medium 
Javascript :: how to read json data from database in laravel 
Javascript :: how to get header in node controller 
Javascript :: axios params onclick function 
Javascript :: how to make react host on https localhost 
Javascript :: make react navigation to always re render 
Javascript :: knockout empty an observable array 
Javascript :: how to check vowels in a string in javascript 
Javascript :: decode jwt token online 
Javascript :: correct code for the { "vars": "local" } 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =