Facebook
From Switch Statemtnt Errors, 3 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 43
  1. ////// WORKIGN CODE ////
  2.  
  3. var firstVar , secondVar , thridVar , forthVar;
  4.  
  5. firstVar = prompt('Enter The First Value of Series!!!');
  6. secondVar = prompt(firstVar + ',');
  7. thridVar = prompt(firstVar + ',' +secondVar + ',');
  8. forthVar = prompt(firstVar + ',' +secondVar + ',' + thridVar + ',');
  9.  
  10.  
  11. var check ;
  12.  
  13. if (  secondVar - firstVar === forthVar - thridVar  )
  14.     {
  15.         check = 0;
  16.     }
  17. else if(secondVar / firstVar === forthVar / thridVar )
  18.        
  19.     {
  20.         check = 2;
  21.     }
  22. else if(secondVar * firstVar === forthVar * thridVar )
  23.     {
  24.         check = 3;
  25.     }
  26. else if(secondVar + firstVar === forthVar + thridVar )
  27.     {
  28.         check = 1;
  29.     }
  30.  
  31.  
  32.  
  33. switch ( check ) {
  34.     case 0:
  35.         console.log('This series is maid by Substion tech:');
  36.         break;
  37.     case 1:
  38.         console.log('This series is maid by Addition tech:');
  39.         break;
  40.     case 2:
  41.         console.log('This series is maid by Division tech:');
  42.         break;
  43.     case 3:
  44.         console.log('This series is maid by Multiplication tech:');
  45.         break;
  46.     default:
  47.         console.log('Invalid Series!!!');
  48. }
  49.  
  50.  
  51.  
  52. //////////// Not Working CODE.
  53.  
  54.  
  55. var firstVar , secondVar , thridVar , forthVar;
  56.  
  57. firstVar = prompt('Enter The First Value of Series!!!');
  58. secondVar = prompt(firstVar + ',');
  59. thridVar = prompt(firstVar + ',' +secondVar + ',');
  60. forthVar = prompt(firstVar + ',' +secondVar + ',' + thridVar + ',');
  61.  
  62.  
  63. var check ;
  64.  
  65. switch (
  66.    
  67. (secondVar - firstVar === forthVar - thridVar ? 0 : null ) ||
  68. (secondVar + firstVar === forthVar + thridVar ? 1 : null)  ||
  69. (secondVar / firstVar === forthVar / thridVar ? 2 : null )  ||
  70. (secondVar * firstVar === forthVar * thridVar ? 3 : null )
  71.  
  72.  
  73. ) {
  74.     case 0:
  75.         console.log('This series is maid by Substion tech:');
  76.         break;
  77.     case 1:
  78.         console.log('This series is maid by Addition tech:');
  79.         break;
  80.     case 2:
  81.         console.log('This series is maid by Division tech:');
  82.         break;
  83.     case 3:
  84.         console.log('This series is maid by Multiplication tech:');
  85.         break;
  86.     default:
  87.         console.log('Invalid Series!!!');
  88. }
  89.  
  90.