In the map callback function, pass in platform for the parameter and implicitly return the creation of a new Platform instance with the platform.x and platform.y values passed in as arguments.
Your code so far
const platforms = platformPositions.map(platform => new Platform(platform.x, platform.y));
This is the code, I am unsure why it isn’t working, I tried doing the same thing in a few different ways and the code isn’t being accepted, what am I doing wrong?
WARNING
The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.
You will need to take an additional step here so the code you wrote presents in an easy to read format.
Please copy/paste all the editor code showing in the challenge from where you just linked.
Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Learn Intermediate OOP by Building a Platformer Game - Step 72
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.
I played around with this and it turns out the tests want you to put parentheses around the platform parameter even though you don’t technically need them.
I would consider this a bug in the tests. Do you want to open a github issue to fix this?
Thanks I will use the backticks next time. No that is okay, I have already opened one up for a previous step, I will also be editing the code once I am done because this is honestly a super janky platformer based on the code when you start to test what you are building. The left and right keys continue to increment like there is acceleration but no code to slow down like in Mario, and he jumps like as if he is a basketball player
Ya, I don’t think this is intended to be a very realistic game. This is a very simple implementation used to teach the basics of javascript. Building a game that respects the laws of physics is probably beyond the scope of this project.