Learn Basic JavaScript by Building a Role Playing Game - Step 90

Hi

I am stuck again i am trying to usee arr.push();

but this is not working …

Thanks

Ian

Your code so far

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/122.0.0.0 Safari/537.36

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 90

Please post your full answer for the buyWeapon function so we can better see what is happening

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 (').


thanks again

Ian

The directions say to push the newWeapon to the inventory array.

with your current code here

you are referencing arr which is not defined and currently not pushing anything.

here is another example of using the push method.

let’s say you had an array of numbers

const numbersArr = [1,2,3,4,5]

if you want to add the number 6 to the end of the array, then you can use the push method like this

numbersArr.push(6)

you need to do something similar for this lesson with the inventory array and the newWeapon variable

1 Like

Yipeee got it and thanks for all your help i can’t thank everyone enough including yourself for all your help
got it now.

Thanks

Ian

 inventory.push(newWeapon);

Thanks for all your help , apprecited

sure no problem.

Also, you only need to place code in code blocks.

Regular text doesn’t need to be in there :+1:

hope that helps

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.