Compare some numbers then determine which one is bigger or smaller.
- Two or more different numbers
- Compare number and number
- Telling which one is bigger or smaller
- Store different numbers into some variables
- Create some
if elsestatement blocks that tell if each number is bigger or smaller than our determined value - Log that results to the console
- Try to compare those numbers with each other
- Expand the
if elsestatements into multiple chains
if (condition) {
// code
} else if (condition) {
// code
} else {
// code
}- Use ternary operator
? :rather thanif elsestatement
condition ? resultA : resultB- Try to compare a variable with value range, with more than 2 conditions, bigger and smaller than some different value at the same time
- Experiment with various kind of operations
min >= condition >= maxconditionA && conditionB- Wrap those logics into some functions that can be called later
- Use parameters to enable us assign different kind of inputs to compare
- You need at least two parameters for these functions
function process(parameterA, parameterB) {
// code
}
process()- Create a random number generator