In this series of blog posts I will write simple JavaScript assignments and solutions for them.
Main purpose of this posts is to practice JavaScript and develop problem solving thinking.
If you have a another solution, please write it in the comment.
Here is the first task:
- Write a program to check two numbers and return true if one of the numbers is 100 or if the sum of the two numbers is 100 */
const checkTwoNum = (a, b) => {
if (a === 100 || b === 100 || (a + b) === 100) {
return true;
} else {
return false;
}
};
//console.log(checkTwoNum(10,90));
Top comments (2)
Hi,
first of all, cool idea!
A small tip I have:
comparing things with === already returns a boolean, so you don't necessarily need the if-statement. You could do
return a === 100 || b === 100 || (a + b) === 100;
This can make the code a little more concise.
Thanks for advice, you're right.