Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrittney Scott
1,801 PointsRandom Array Project
How do I get code to run by clicking the play button so that two random numbers for two players competing to get the highest number reveals in the console?
9 Answers
Brittney Scott
1,801 PointsI thought I corrected all of the lines you mentioned again. For instance, Line 25 was corrected to function diceRoll{(array)
Steven Parker
231,153 PointsCreating an event listener on the button for the "click" event is what allows the button to work. But it uses other parts of the code, so that won't work until you have coded all the individual steps.
If you've completely coded everything and it's still not working, post a fresh snapshot.
Brittney Scott
1,801 PointsSteven Parker
231,153 PointsThere's a few code issues:
- line 25: there's a stray brace (and space) between the function name and the parentheses
- lines 48/49: these should be new varaibles ("scoreOneElement" and "scoreTwoElement" are already used)
- also 48/49: new variables need the "let" or "var" keyword to declare them
- line 52: not needed, duplicate of 55
- line 55: should be logging the new variables with values and not the elements
- step 6 says to use "innerHTML" instead of "textContent"
- lines 59/60: should assign from the new variables instead of calling "diceRoll" again
- line 68: there's a stray undefined identifier "cccccc" at the end of the line
Brittney Scott
1,801 PointsCan you take a look please. I'm stuck. Please help
Steven Parker
231,153 PointsThose new variables on lines 48/49 need unique names, "scoreOneElement" and "scoreTwoElement" are already taken. Then the other lines where they are used will need to be updated, and 59 and 60 will use them instead of "twelveSidedDie".
Brittney Scott
1,801 PointsIs this right? https://w.trhou.se/nabvid2w18
Steven Parker
231,153 PointsMaybe you got a bit hasty, read the comment for step 6 again carefully:
// 6) Set the innerHTML of the `scoreOneElement` and `scoreTwoElement` variables above equal to the dice roll variables you just created
Brittney Scott
1,801 PointsWhat about now?
Steven Parker
231,153 PointsThe button will work when the errors have been fixed, assuming no new problems are created.
The remaining issues are on lines 25, 48, 49, 59, 60.
Brittney Scott
1,801 PointsI don't know what I am doing wrong. Very frustrated because it is due soon. I do not know what it should be corrrected to. https://w.trhou.se/mke8rlpbij
Steven Parker
231,153 PointsFrustration may be becoming an obstacle in itself. It could be time for a break. Come back fresh and the instructions in the comments combined with the hints given here may make more sense.
Brittney Scott
1,801 PointsI cannot get play button to work
Steven Parker
231,153 PointsOnce you've checked all the hints and the comments in the instructions again, and made your best effort to fix those 5 lines with issues, post a fresh snapshot link.
Brittney Scott
1,801 PointsI really hope this is correct... Line 6 towards the bottom, not sure if correct but I believe so. Play button works! Can someone take a look please....https://w.trhou.se/vn763371we
Steven Parker
231,153 PointsThat snapshot doesn't exist, did you delete the workspace it was made from?
Try making a fresh one ... or did you get things working?
Brittney Scott
1,801 PointsSorry for the delay in response. Yes! I was able to get the code running. Thanks for all your help.
Steven Parker
231,153 PointsBrittney Scott — Glad to help. You can mark the question solved by choosing a "best answer".
And happy coding!
Steven Parker
231,153 PointsSteven Parker
231,153 PointsThe very first hint was "line 25: there's a stray brace ... between the function name and the parentheses"
But that still needs fixing.
Get some rest and come back to it fresh.