Monday, August 12, 2013

function - arguntent types

Now let's say we want to make sure that the caller always gets a numeric value back, even if the input wasn't of the right type.
To achieve that, we need to check the type of the argument that was passed in. If it wasn't a number, we probably shouldn't try to multiply it. We'll just return 0 in that case.

var cube = function (x) {
     if (typeof(x) !== 'number') return 0;
    return x * x * x;
};

// Once you uncomment the type check in line 2,
// the cube() function should return 0.
cube("test");

Sunday, August 11, 2013


> CSS: http://jigsaw.w3
> org/css-validator/validator?profile=css21&warning=0&uri=http%3A%2F%2Fwww
> turningleafwebanddesign.com%2Fhops%2Ftest-page.html [ Ignore any properly
> formed CSS 3 rules that are flagged ]

> HTML: http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww
> turningleafwebanddesign.com%2Fhops%2Ftest-page.html [ Just correct the
> errors you have control over ]

> Validating:

> CSS: http://jigsaw.w3.org/css-validator/
> HTML: http://validator.w3.org/#validate_by_uri+with_options
> Unicorn - W3C's Unified Validator: http://validator.w3.org/unicorn/ 

Friday, August 2, 2013

rock scissors paper

var userChoice = prompt("Do you choose rock, paper or scissors?");
 var computerChoice = Math.random();

    if (computerChoice < 0.34)
        {
            computerChoice = "rock";
        }
    else if(computerChoice <= 0.67)
        {
            computerChoice = "paper";
        }
    else
        {
            computerChoice = "scissors";
        }

    var compare = function(choice1, choice2)
    {
      if (choice1 === choice2)
      {
     return "The result is a tie!";
      }
// CHOICE1 = ROCK
      if (choice1 === "rock")
      {
          if (choice2 === "scissors")
          {  return "rock wins";
          }
          else {  return "paper wins";
          }
        }
//CHOICE1 = PAPER       
    if (choice1 ==="paper")
    {
       if (choice2 === "rock")
       { return "paper wins";
       }
       else { return "scissors wins";
       }
    }  
// choice1 = scissors
 if (choice1 === "scissors")
   {
       if (choice2 === "rock")
       { return("rocks wins");
       }
       else { return ("scissors wins");
       }
   }
   
    };
   
    compare(userChoice, computerChoice);