Tell us what’s happening:
Hi I am just learning javascript so don’t know exactly what i am doing f
so thanks for all your help
function buyWeapon() {currentWeaponIndex += 1
if (gold >= 30) {
gold -= 30;
}
}
what am i doing wrong. thanks.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function buyWeapon() {currentWeaponIndex += 1
if (gold >= 30) {
gold -= 30;
}
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 84
1 Like
ILM
June 8, 2024, 9:42pm
2
here when the gold is subtracted you should increase currentWeaponIndex to give the player the new just purchased weapon
Ray13
June 8, 2024, 9:49pm
3
I’ve edited your post for readability. Next time please don’t use backticks in this form to describe your issue. Thanks.
1 Like
function buyWeapon() {currentWeaponIndex += 1
if (gold >= 30) {
gold -= 30;
currentWeaponIndex += 1;
}
}
is this whaat you mean thanks
ILM
June 8, 2024, 10:38pm
5
yes, but you are increasing the index twice, it should be only once
it still doesn’t pass but thanks everyone for all your help
function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeaponIndex += 1;
}
}
ILM
June 9, 2024, 11:31am
7
Your solution works from my end. Please try one of the following steps to move forward.
Click on the “Restart Step” button and force a refresh of your page with CTRL + F5 then try to paste the code in again.
or - Try the step in incognito or private mode.
or - Disable any/all extensions that interface with the freeCodeCamp website (such as Dark Mode, Ad Blockers, or Spellcheckers), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.
or - Ensure your browser is up-to-date or try a different browser.
I hope one of these will work for you.
1 Like
i am using a google chromebook on these webpages so don’t `have a f5 key
thanks anyway still not passing i will eventually solve it.
hi
this still is not passing so i have been stuck on this for a while thanks for all your help in advance
ian
The code is fine, no one can help you with that.
Try on a different computer
1 Like
why does everything else pass on my chromebook as i dont have a different computer thanks.
I don’t know.
Your code is correct, I would test it on a different browser or machine to test. Can you install a different browser? Firefox?
Try it on your phone?
1 Like
will do i will let you know how i get on thanks.
ILM
June 23, 2024, 10:40am
14
alternatively, you can just proceed to next step
1 Like
Thanks everyone i remembered i have an very old laptop and used that but the great news is it passes now so tell everyone who maybe using a google chromebook it will not pass on them thanks.
1 Like
``it does work on a google chromebook as i went back to the start and started again
currentWeaponIndex +=;
this is what i used and it passed so not the full working solution but you can probably work out what is missing thanks it passes now.