Labs

Resources for this lab: resources/labs

  1. The function fahrToCels should convert a Fahrenheit temperature to Celsius. Complete the body of the function such that it will take a Fahrenheit parameter, and convert it into Celsius.

    function fahrToCels(fahr) {
      let cels;
      /*********Your Solution ********/
    
      /*******************************/
      return cels;
    }
    
  2. The function celsToFahr should convert a Celsius temperature Celsius parameter, and convert it into Fahrenheit.

    function CelsToFahr(cels) {
      let fahr;
      /*********Your Solution ********/
    
      /*******************************/
      return fahr;
    }
    
  3. Complete the following sum function:

    function sum(x,y) {
      let total;
      /*********Your Solution ********/
    
      /*******************************/
      return total;
    }
    
  4. Complete the isEven function, returning a boolean if the argument num is even and a number.

    function isEven(num) {
      let bool;
      /*********Your Solution ********/
    
      /*******************************/
      return bool;
    }
    
  5. Use a ternary operator in the following styleMeltdownWarningNotification function to return the string 'red' if the parameter coolentLvl is less than 80, or the string 'green' if coolentLvl is 80 or above. If the input value is not a number, return 'red' (as something is clearly wrong);

    function styleMeltdownWarningNotification(coolentLvl) {
      let color;
      /*********Your Solution ********/  
    
      /*******************************/
      return color;
    }
    
  6. Modify the randomWholeNumberGenerator(maximumNumberValue) function to return either a random number between 0 and the number provided as an argument; if the result would be NaN, return 0. Do NOT use an if/else to accomplish this (ternary).

To generate a random number between 0-1, use the Math.random() method.

```js
function randomWholeNumberGenerator(maximumNumberValue) {
  let randomNum;
  /*********Your Solution ********/  

  /*******************************/
  return randomNum;
}
```

Prev -- Up