Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Project 3 SDI
- //Joel Betterly
- //December 8 2011
- //Theme: Superman
- //Global Variables
- var superman = "Clark Kent",
- homePlanet = "Krypton",
- superHeros = ["Batman", "Spider-Man", "Hulk", "Wonder Woman", "Green lantern"]
- ;
- console.log ("Look! Up in the sky! Is it a bird? Is it a plane? NO! It's Superman!");
- //Procedure conditional with nested conditional
- var identity = function () {
- if (superman == "Clark Kent") {
- console.log ("Our mild manner reporter's identity is safe.");
- }else{
- if (superman == "Kal-el") {
- console.log ("Oh no, somebody knows too much");
- }else{
- console.log ("There is evil abound, we must help Superman.");
- };
- };
- };
- //While Loop with local variables and Number Argument and number return
- var justiceLeague = function(f1,f2,fights) {
- var frienEnemies = 0
- var frienEnemies2 = 0
- while(f1<10) {
- if (frienEnemies == 0){
- 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!");
- }
- frienEnemies = frienEnemies + 1;
- f1++;
- }
- while(f2<20) {
- frienEnemies2 = frienEnemies2 + 1;
- if (frienEnemies2 == 20){
- 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.");
- }
- f2++;
- }
- }
- // YOU WILL NEVER GET INSDIE THIS "IF" STATEMENT BECAUSE YOU ARE SETTING THE VALUE OF "frienEnemies" TO 10
- // BEFORE THIS IF STATEMENT EVER GETS CALLED. IF YOU WANT THIS TO FIRE YOU WILL NEED TO MOVE IT INSIDE THE
- // 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"
- /*
- if (frienEnemies == 0) {
- 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!");
- return frienEnemies;
- }else if (frienEnemies2 == 20){
- 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.");
- } <- THIS DOESN'T NEED TO BE HERE
- return frienEnemies2;
- };
- */
- //String Function
- var stringFunc = function(a, b){
- var clothesToWear = a;
- var clothesToWear2 = b;
- var output
- output = ("To fight bad guys we must wear a " + clothesToWear + ". While in disguise, we can dress in " + clothesToWear2 + ".");
- return output;
- };
- //Boolean with argument and return
- var readyToFly = function (cape){
- if (cape == true) {
- console.log ("Looks like Superman has his outfit on and is ready to fly.");
- } else {
- cape = console.log("Superman must do a quick change before he is ready to fly.");
- };
- return cape;
- };
- //Array Function with Aurgument and return
- var battleReady = function (a, b){
- var superPower = false;
- var weak = b;
- var a,
- output
- ;
- if (superPower == true) {
- for (var s=0; s<a; s++){
- output = (a + "Superpower is good to go.");
- }
- }else{
- for (var i=0; i< 1; i++){
- output = (b + " does not have any real superpower and is not ready.");
- }
- };
- return output;
- };
- // Procedure return
- identity();
- //Number return
- justiceLeague(0,0,2);
- //String Function with returned Output
- getWearing = stringFunc("cape and suit", "glasses and suit");
- console.log(getWearing);
- //Boolean with return
- readyToFly(false);
- //Array with return
- getSuperHeros = battleReady(3, superHeros[3])
- console.log (getSuperHeros)
Add Comment
Please, Sign In to add comment