dnestoff
9/17/2016 - 4:40 PM

Javascript: Basic Syntax

// load before </body>

<script src="jquery.min.js"></script>
  <script src="application.js"></script>
// basic document ready syntax

jQuery(document).ready(function () {
  
  });
//Function names should begin with a lowercase letter
// the convention is to use lowerCamelCase where each word (except the first) 
//begins with a capital letter.

var greeting = function (name) {
    console.log("Great to see you," + " " + name);
};

greeting("Ron")

//########################################################

//if statements
var sleepCheck = function(numHours) {
    if (numHours >= 8) {
        return "You're getting plenty of sleep! Maybe even too much!";
        } else {
        return "Get some more shut eye!";
    }
}

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