As we learned before, when we define procedures in python, we used "def." However, in JavaScript, we use function as opposed to def in python. Here is a basic procedure to start with. With python we would define the function with "def" but here we are using "function." After that, it is nearly the same for the rest of the program.

function subtraction(a,b) {
    return a - b;
  }
  
  subtraction(10,12)
-2

Example 1: Postive and Negatives Procedure

function plusMinus(arr) {
    var pos = 0;
    var neg = 0;
    var zero = 0;
    
    var length = arr.length;
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] > 0) {
          pos += 1;
        } else if (arr[i] < 0) {
          neg += 1;
        } else {
          zero += 1;
        }
      }
     console.log("There are " + arr.length + " total numbers");
     console.log("There are " + pos + " positive numbers");
     console.log("There are " + neg + " negative numbers");
     console.log("There are " + zero + " zeroes");
    }

    var array = [1, 1, 0 , -1, -1];
    plusMinus(array);
There are 5 total numbers
There are 2 positive numbers
There are 2 negative numbers
There are 1 zeroes

Example 2: Time Conversion Procedure

function timeConversion(s) {
  var arr = s.slice(0,8).split(':');
  arr[0] = (s.indexOf('PM') > -1) ?
           (arr[0] == 12 ? '12' : Number(arr[0]) + 12) :
           (arr[0] == 12 ? '00' : arr[0]);
  console.log(arr.join(':'));
  }

  var input = "07:05:45PM";
  timeConversion(input);
19:05:45

Challenge 2: Min and Max (Bonus 0.1 points): You can do this whole thing in either Python or JavaScript.

// Start by creating a procedure called findMax and set the parameters to numberA and numberB.

// Within the procedure, write the code to determine which of the two parameters, numberA or numberB, is the larger value. Print that value.

// Repeat the process, this time creating a procedure called findMin, which will print the parameter with a smaller value.

// Call both functions so that the parameters numberA and numberB are given a value.

// Optional bonus- create a procedure that can determine the minimum or maximum value out of more than two parameters.