Monday, May 10, 2021

Javascript Practice 44: JS Hero - Strict inequality

 
Question: 

Write a function unequal that checks 3 values for strict inequality. The function should return true if all three parameters are strict unequal. Otherwise false.

Example: unequal(1, 2, 3) should return true and unequal(1, 1, 2) should return false.




Answer: 

function unequal (a,b,c) {

return a !== b && b !== c && a !== c; 

}; 

> declare a function unequal 
> it has 3 parameters
> return statement is: a !== b && b !== c && a !== c
> it checks for strict inequality between the 3 parameters
> it will return true of all parameters are strictly unequal
> it will return false if any 2 or all 3 of them are equal

No comments:

Post a Comment