mikereeve
3/22/2020 - 11:27 PM

Procedure vs Function

//Procedure a collection of things we want it to do
// greetStudent takes a student object - we know its an object because of ${student.name} we are going to access first the student then the name
// ` tick marks (found on the keyboard with the tilde symbol) is a interpolated string - all that means is where we are going to put other variable ->
// values into directly inside of the string. ${student.name} means go find what we are looking for and put it inside of the string.
// its a procedure and uses the word function to denote it and has a name called greetStudent. It has a (student) is a parameter its the input ->
// but its considered a procedure because its not giving us a value back - a function would give us a value back to us.

function greetStudent(student){
  console.log(
    `Hello, ${student.name}!`
    );
}
// a function called timeRemaining with 2 inputs, timeRemaining and endTime both are called parameters

function timeRemaining(timeElapsed, endTime){
  return endTime - timeElapsed;
}

var left = timeRemaining (42, 240);
left;  //198