How to solve task 127 without using any "if " statement.

Hints:

  1. You can return the boolean value without an if using the return statement.
  2. You can use the operators && and || to combine boolean values.

    Oh boy! This one gave me a headache 😅 were you successful with the explanation @juju?

      10 days later

      A quick note about this including my solution, Heroes. This is one of those issues where I originally tried a more complex set of calculations outside of an if statement. Truth be told, this ended up being a lesson in simplicity. Using the return statement, this ended up being my HELPER.JS

      export const oneWillDo = (x, y, z) => {
      return x + y + z >= 1;
      }

      Basically, this uses the mathematical equivalent of true and false (0 and 1) and say that any combination of those values would create a mathematical construct that was 1 or more for all truthy statements. I would say I'm about 85% sure of it, but the autograder said it was good to go.

      TTFN,
      GM

        MisterManley that's a clever solution 🙂

        a more straightforward combo would be to use the || operator instead of +

        As a || b returns true if either a OR b are true

        3 months later

        This solution worked for me

        export const oneWillDo = (x, y, z) => {
        return x | | y | | z === true;
        };

        4 months later

        Oluwatomisin_Joy you should never copy someone else's code. If you don't understand it's ok, but you should crack the problem on your own.

        Ask questions, and come up with ideas, but don't look for shortcuts.

          11 days later

          Oluwatomisin_Joy this solution worked for me
          export const oneWillDo = (x, y, z) => {
          return x or y or z == true;
          }
          If I'm right this solution is checking if anyone of x, y and z is true then it will return true otherwise it will give false. For deep understanding please look at the values given in solution.js file . I have written "or" instead of in the solution because it was not showing . So, please don't be confused.

          2 months later
          23 days later
          Write a Reply...