// Fun With Function // Variables store something // Functions do something // ***Put all this in the console in Chrome to test out // Most basic function // Function Declaration or Definition var ourfirstfunction = function(){ console.log("Hello class") } var sayhello = function(){ console.log("Hello" + "you") } var sayhello = function(username){ console.log("Hello" + username) } // Type out sayhello(), can put a phrase into (), will spit out "HelloPhrase" var sayhello = function(username){ var username = "Matt" console.log("Hello" + username) } // Same result as up above when inputting sayhello() var drawcats = function(howmanytimes){ for (var i = 0; i < howmanytimes; i++){ console.log(i + "=^.^=") } } // Input drawcats(#), will draw out what you put in a set number of times var printmultipletimes = function(howmanytimes,whattodraw){ for(var i = 0; i < howmanytimes; i++){ console.log(i + " " + whattodraw) } } // Input printmultipletimes(#, "=^.^=") var drawthreecats = function(){ console.log("Before the Return") return "=^.^= =^.^= =^.^=" } var triple = function(passednumberargument){ // Do something with argments var x = passednumberargument * 3 // Then return the "result" return x } var fifthletter = function(name){ if(name.length < 5){ return "Sorry your name is too short, try a longer one" } return "The Fifth Letter of your name is " + name[4] + "." } // Inpt fifthletter("name"), will give you the fifth letter // If the name has less than five letters, it will give you the return message var gradeforscore = function(score){ if (score >= 90){ return "A" } if (score < 90 && score >= 80){ return "B" } if (score < 80 && score > 70){ return "C" } if (score < 70 && score >= 60){ return "D" } if (score < 60){ return "F" } }