Ternary operator return check error

I am in step 11 of Javascript Platformer game.

Step 11

Task :
The width and the height of the main player, platforms and checkpoints will be proportional sized relative to the innerHeight of the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes.

Inside your proportionalSize function, you will need to return a ternary that checks if innerHeight is less than 500. If so, return Math.ceil((size / 500) * innerHeight), otherwise return size.

I did

const proportionalSize = (size) => (innerHeight < 500) ? Math.ceil((size / 500) * innerHeight) : size;

What is wrong here ?

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

The proportionalSize function was originally:

const proportionalSize = (size) => {
  
};

Notice the curly braces. I don’t think the tests want you to remove those curly braces. I think your solution is fine, it’s just not what the tests are expecting.

1 Like

I was searching for a way to format code lines, but I could not find as I am new to this forum. Thank you.

1 Like