Labs
Resources for this lab: resources/labs
-
The function
fahrToCelsshould 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; } -
The function
celsToFahrshould convert a Celsius temperature Celsius parameter, and convert it into Fahrenheit.function CelsToFahr(cels) { let fahr; /*********Your Solution ********/ /*******************************/ return fahr; } -
Complete the following
sumfunction:function sum(x,y) { let total; /*********Your Solution ********/ /*******************************/ return total; } -
Complete the
isEvenfunction, returning a boolean if the argumentnumis even and a number.function isEven(num) { let bool; /*********Your Solution ********/ /*******************************/ return bool; } -
Use a ternary operator in the following
styleMeltdownWarningNotificationfunction to return the string 'red' if the parametercoolentLvlis less than 80, or the string 'green' ifcoolentLvlis 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; } -
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;
}
```