CIS 111 Lecture 2: Chpts 3,4,9,10,15,21,22,23
![](https://new-preview-html.oneclass.com/6YPy0AD8OkL3m1bZkZq0jaBe7J2KRExq/bg1.png)
Chpts 3,4,9,10,15,21,22,23 (Wk 2)
• What we will cover
o Ch. 3: Functions
o Ch. 4: Selection Statements
o Ch. 9: .js Files
o Ch. 10: Comments & Style Guide (Beautify)
o Ch. 15: Numbers && Operators
• Chpt 3: Functions
o Built-in Functions
▪ Functions are like Lego Blocks
• functions can be used in many different programs
• Programs can be assembled quickly by building them with functions
o alert(“message”); //does not return value
o console.log(“message”); //does not return a value
o prompt(“message”); //returns a value of type string
o Math.pow(2,3); //returns 8
o Math.min(4.5,5); //returns 4.5
• Chpt 15: The Math Object
Function
What it Does
Math.pow()
Raises a # to a specified power
Math.exp()
Raises the Euler’s constant to a specified #
Math.sqrt()
Raises the square root of a giving argument
• Chpt 27: Open the DevTools Console
o A function is a group of statements that performs a particular task
▪ To create a function, we can use a Function Declaration:
• //Declare the function
function sayHello() {
console.log(“Hello!”);
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
Chpts 3,4,9,10,15,21,22,23 (wk 2: what we will cover, ch. 10: comments & style guide (beautify: ch. Math. pow() raises a # to a specified power. Math. exp() raises the euler"s constant to a specified # Math. sqrt() raises the square root of a giving argument: chpt 27: open the devtools console, a function is a group of statements that performs a particular task, to create a function, we can use a function declaration: Chpts 3,4,9,10,15,21,22,23 (wk 2: a function that accepts an argument, eg. //define the function function sayhellobyname(fname) { console. log( hello, + fname + ! ); //call the function console. log( start of program ); sayhellobyname( luna ); var firstname = prompt( enter your first name ); sayhellobyname(firstname); console. log( end of program ): parameters & arguments, parameters are in the function definition, arguments are in the function call. //name is a parameter function sayhellobyname(fname) { console. log( hello, + fname + ! );