Comp 110 random

What is the 'random' function?

Like all of our introcs functions, random needs to be imported!

import { random } from "introcs";

This is what our function definition looks like!

let random = (floor: number, ceiling: number): number => {

     //...

}

random takes in two number arguments that act as the 'floor' and the 'ceiling'...the number that is returned as a result from the function will return a randomly generated number between the floor and the ceiling (inclusively! AKA >= floor and <= ceiling)

Example of use:

let whereShouldIGo = () : string => {
     let randomNumber: number = random(1,4);
     if(randomNumber === 1) {
          return "Old Well";
     } else if(randomNumber === 2) {
          return "Bell Tower";
     } else if(randomNumber === 3) {
          return "Dean Dome";
     } else {
          return "Franklin Street";
     }
}

//whatever number is generated will determine what string is printed!