87.8k views
1 vote
The number 6 is a truly great number. Given two int values, a and b, return true if either one is 6. Or if their sum or difference is 6. Note: the function Math.abs(num) computes the absolute value of a number.

A love6(6, 4) → true
B love6(4, 5) → false
C love6(1, 5) → true

User Asidis
by
8.6k points

1 Answer

6 votes

Final answer:

To determine if either of the two integer values is 6, or if their sum or difference is 6, we can use conditional statements.

Step-by-step explanation:

In this question, we are given two integer values, a and b, and we need to determine whether either one is 6, or if their sum or difference is 6. To solve this, we can use conditional statements to check each condition.

First, we check if a or b is equal to 6. If either condition is true, we return true.

Next, we check if the sum of a and b is equal to 6. If this condition is true, we return true. Finally, we check if the absolute difference between a and b is equal to 6. If this condition is true, we return true. If none of the conditions are true, we return false.

Example:

love6(6, 4) // returns true

love6(4, 5) // returns false

love6(1, 5) // returns true

User Jczaplew
by
8.3k points