Monday, May 10, 2021

Javascript Practice 45: JS Hero - Compare numbers

 
Question: 

Write a function isThreeDigit that checks if a number is greater than or equal to 100 and less than 1000.

Example: isThreeDigit(500) should return true and isThreeDigit(50) should return false.




Answer: 

function isThreeDigit (n) { 

return n >= 100 && n < 1000; 

}; 


> create a function isThreeDigit
> has one parameter
> return statement is: n >= 100 && n < 1000
> two conditions passed for result to come true
> n has to be greater then or equal to 100 & less than 1000 

No comments:

Post a Comment