Build a Boolean Check Function - Build a Boolean Check Function

Tell us what’s happening:

I can pass tests 1 to 3 but I’m stumped beyond that. I can’t figure out how to make everything but true and false to return as false.

Your code so far

function booWho(){
  if (true){
    return true;
  }
  else return false;
}


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0

Challenge Information:

Build a Boolean Check Function - Build a Boolean Check Function
https://www.freecodecamp.org/learn/full-stack-developer/lab-boolean-check/build-a-boolean-check-function

You should have a function called booWho that receives one argument.

Does your function accept an argument?

Will this condition ever evaluate as false?

I don’t get what the instructions are asking for. Or well I understand a bit but I’m having trouble figuring out the rest. Like I have no clue what kind of an argument it’s looking for. and because I struggle with the argument I can’t really do much about the condition. For me the instructions are often way too vague and I have hard time understanding what I’m supposed to do.

1 Like

you can see example of arguments in the tests

  1. You should have a booWho function.
  2. booWho(true) should return true.
  3. booWho(false) should return true.
  4. booWho([1, 2, 3]) should return false.
  5. booWho([].slice) should return false.
  6. booWho({ "a": 1 }) should return false.
  7. booWho(1) should return false.
  8. booWho(NaN) should return false.
  9. booWho("a") should return false.
  10. booWho("true") should return false.
  11. booWho("false") should return false.

If the argument is true or false the function needs to return true as this is a Boolean
For everything else the function needs to return false

Do you know how to check what kind of value is a variable?

For a function to take an argument, you will need a parameter in your function definition.

EXAMPLE:

function multiplyByTen(num) {
    return num*10
}

console.log(multiplyByTen(10)) // 100

In the above example, the parameter is num and the argument (supplied to the parameter when the function is called) is 10.

So, in your function definition, you need to have a parameter. Inside the function body you need to evaluate if any value passed as an argument (via your parameter) is a boolean primitive or not. Essentially, you need to determine what type of value is passed to the function when it is called. There is a method which can be used to do exactly this.

Thanks I finally figured it out! It was a lot simpler than I thought as it usually is. :sweat_smile: But then again I didn’t know I needed to check the type before you pointed it out.

1 Like