0

I'm trying to write a function, but it's doing the opposite of what I'd like.

Write a function that determines whether a user is old and tall enough to ride a roller coaster. The function should take an object as a parameter. If the object's age property is greater than or equal to 7 and the height property is greater than or equal to 42, return true. Otherwise, return false

 const rollerCoaster = (object) => {
  if (object.age >= 7 && object.height >= 42) {
      return true
  } else {
      return false
  }
}

console.log(rollerCoaster(55, 55));

This is returning false, we want it to return true. What am I missing?

2
  • 2
    Your call to the function is passing two number parameters instead of one object. Try console.log(rollerCoaster({age: 55, height: 55})) Commented Nov 25, 2018 at 23:03
  • yup, you're right, thanks for that Commented Nov 25, 2018 at 23:05

1 Answer 1

4

You are passing in two numbers as the parameters, rather than an object. The function is not working because referencing the number as an object returns undefined or null, therefore making the function return false.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.