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!

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 trial

JavaScript

How do I uncomment this array: const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; I am so confused. Help.

How do I uncomment this array: const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; I am so confused. Help.

2 Answers

Steven Parker
Steven Parker
224,864 Points

That bit of code does not appear to be currently "commented". A comment would start with two slashes ("//") or a slash and an asterisk ("/*").

It would be easier to help if you can show the whole code, and perhaps a link to the course page you are working with.

/* Variable to store play button by id for event listener assignment below - You can ignore this */ const playBtn = document.querySelector('#play-btn');

/* Variables to store DOM elements that display player's scores - You'll use these variables in the event listener below */ const scoreOneElement = document.querySelector('#score-1'); const scoreTwoElement = document.querySelector('#score-2');

// YOUR CODE GOES HERE!!! Do the steps below to complete this challenge

// 1) Uncomment the array below //const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];

// 2) Create a function named diceRoll. Give it a parameter called array — this goes in the parens. player.stamina = 6 + DiceRoll("1d6") msg ("Stamina: " + player.stamina) // 2a) Create a variable that uses Math.ceil, Math.random and the length of the array parameter Array.from({length: 40}, () => Math.floor(Math.random() * 40)); // NOTE: Introducing Functions video — https://teamtreehouse.com/library/introducing-functions-5 // NOTE: Create a Random Number video — https://teamtreehouse.com/library/javascript-basics/working-with-numbers/create-a-random-number

// 2b) return the random number variable var foo = getRandomNumber(0, 40); console.log(foo);

Steven Parker
Steven Parker
224,864 Points

When posting code to the forum, use Markdown formatting to preserve the appearance, or share the entire workspace by making a snapshot and posting the link to it.

But if you have lines like this (shown here using Markdown):

// 1) Uncomment the array below
//const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];

There are two copies of the array here, the first one is "commented" and the last one is "uncommented" (active).

Is there anything wrong here:

/* Variable to store play button by id for event listener assignment below - You can ignore this */ const playBtn = document.querySelector('#play-btn');

/* Variables to store DOM elements that display player's scores - You'll use these variables in the event listener below */ const scoreOneElement = document.querySelector('#score-1'); const scoreTwoElement = document.querySelector('#score-2');

// YOUR CODE GOES HERE!!! Do the steps below to complete this challenge

// 1) Uncomment the array below //const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; const twelveSidedDie = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];

// 2) Create a function named diceRoll. Give it a parameter called array — this goes in the parens. player.stamina = 6 + DiceRoll("1d6") msg ("Stamina: " + player.stamina) // 2a) Create a variable that uses Math.ceil, Math.random and the length of the array parameter Array.from({length: 40}, () => Math.floor(Math.random() * 40)); // NOTE: Introducing Functions video — https://teamtreehouse.com/library/introducing-functions-5 // NOTE: Create a Random Number video — https://teamtreehouse.com/library/javascript-basics/working-with-numbers/create-a-random-number

// 2b) return the random number variable var foo = getRandomNumber(0, 40); console.log(foo);

Steven Parker
Steven Parker
224,864 Points

This code references things not shown here (including some HTML parts), so it's not possible to fully evaluate it. The "snapshot" mentioned before (with the instructional video linked to it) is the best way to share for analysis, because it contains all the code as well as the testing environment to make it easy to replicate the issue.