Guest User

Untitled

a guest
Apr 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Project 3 SDI
  2. //Joel Betterly
  3. //December 8 2011
  4. //Theme: Superman
  5.  
  6. //Global Variables
  7. var superman = "Clark Kent",
  8.     homePlanet = "Krypton",
  9.     superHeros = ["Batman", "Spider-Man", "Hulk", "Wonder Woman", "Green lantern"]
  10. ;    
  11.    
  12. console.log ("Look! Up in the sky! Is it a bird? Is it a plane? NO! It's Superman!");
  13.    
  14. //Procedure conditional with nested conditional
  15. var identity = function () {
  16.  
  17.   if (superman == "Clark Kent") {
  18.     console.log ("Our mild manner reporter's identity is safe.");
  19.    
  20.     }else{
  21.      
  22.       if (superman == "Kal-el") {
  23.           console.log ("Oh no, somebody knows too much");
  24.          
  25.         }else{
  26.           console.log ("There is evil abound, we must help Superman.");
  27.          };
  28.              };
  29. };
  30.  
  31. //While Loop with local variables and Number Argument and number return
  32. var justiceLeague = function(f1,f2,fights) {
  33.   var frienEnemies = 0
  34.   var frienEnemies2 = 0
  35.  
  36.     while(f1<10) {
  37.    
  38.         if (frienEnemies == 0){
  39.         console.log ("Some friends are not always friends. We had " + frienEnemies * fights +" battles and Superman was the only one to show up at every fight!");
  40.       }
  41.      
  42.     frienEnemies = frienEnemies + 1;
  43.     f1++;
  44.   }
  45.  
  46.     while(f2<20) {
  47.     frienEnemies2 = frienEnemies2 + 1;
  48.  
  49.     if (frienEnemies2 == 20){
  50.         console.log ("Some friends are not always friends. We had " + frienEnemies2 * fights +" battles and Superman was the only one to show up at every fight.");
  51.     }
  52.    
  53.     f2++;
  54.   }
  55. }
  56.  
  57.   // YOU WILL NEVER GET INSDIE THIS "IF" STATEMENT BECAUSE YOU ARE SETTING THE VALUE OF "frienEnemies" TO 10
  58.   // BEFORE THIS IF STATEMENT EVER GETS CALLED. IF YOU WANT THIS TO FIRE YOU WILL NEED TO MOVE IT INSIDE THE
  59.   // WHILE LOOP "while(f1<10)". I MOVED IT INTO YOUR WHILE LOOP ALONG WITH YOUR OTHER console.log. ALSO, YOU HAVE AN EXTRA BRACKET INSIDE YOUR "else if" STATEMENT DIRECTLY AFTER THE "console.log"
  60.   /*
  61.         if (frienEnemies == 0) {
  62.           console.log ("Some friends are not always friends. We had " + frienEnemies * fights +" battles and Superman was the only one to show up at every fight!");
  63.          
  64.           return frienEnemies;
  65.          
  66.         }else if (frienEnemies2 == 20){
  67.           console.log ("Some friends are not always friends. We had " + frienEnemies2 * fights +" battles and Superman was the only one to show up at every fight.");
  68.           } <- THIS DOESN'T NEED TO BE HERE
  69.    
  70.           return frienEnemies2;
  71.    
  72.         };
  73.   */
  74.  
  75. //String Function
  76. var stringFunc = function(a, b){
  77.     var clothesToWear = a;
  78.     var clothesToWear2 = b;
  79.     var output
  80.    
  81.     output = ("To fight bad guys we must wear a " + clothesToWear + ". While in disguise, we can dress in " + clothesToWear2 + ".");
  82.  
  83.     return output;
  84.  
  85. };
  86.  
  87. //Boolean with argument and return
  88. var readyToFly = function (cape){
  89.  
  90.     if (cape == true) {
  91.       console.log ("Looks like Superman has his outfit on and is ready to fly.");
  92.    
  93.     } else {
  94.       cape = console.log("Superman must do a quick change before he is ready to fly.");
  95. };
  96.      return cape;
  97. };
  98.  
  99. //Array Function with Aurgument and return
  100. var battleReady = function (a, b){
  101.     var superPower = false;
  102.     var weak = b;
  103.     var a,
  104.         output
  105. ;
  106.    
  107.   if (superPower == true) {
  108.       for (var s=0; s<a; s++){
  109.       output = (a + "Superpower is good to go.");
  110.                               }
  111.        
  112.   }else{
  113.       for (var i=0; i< 1; i++){
  114.       output = (b + " does not have any real superpower and is not ready.");  
  115.                                }
  116.  
  117.   };
  118.   return output;
  119. };
  120.  
  121. // Procedure return
  122. identity();
  123.  
  124. //Number return
  125. justiceLeague(0,0,2);
  126.  
  127. //String Function with returned Output
  128. getWearing = stringFunc("cape and suit", "glasses and suit");
  129. console.log(getWearing);
  130.  
  131. //Boolean with return
  132. readyToFly(false);
  133.  
  134. //Array with return
  135. getSuperHeros = battleReady(3, superHeros[3])
  136. console.log (getSuperHeros)
Add Comment
Please, Sign In to add comment