DEV Community

Milan Matejic
Milan Matejic

Posted on

JavaScript assignments - 1

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:

  1. 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)

Collapse
 
raphael_haecker profile image
Raphael Häcker

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.

Collapse
 
mateja3m profile image
Milan Matejic

Thanks for advice, you're right.