Tic Tac Toe help - how to remove hashtags?

How do I remove the hashtag from the buttons and have the code still work? I’ve tried empty spaces and can’t find a way to get around it.

If you want to replace the hashtag with a space or an empty string, you will need to do so EVERY place you see a hashtag in your code. I changed the hashtag to “” throughout your code and it works fine. The only catch is you will need to modify your CSS, so that the squares remain the same says with the empty string or X or O character.

1 Like

That didn’t work unfortunately.

Did you by chance use your editor’s replace feature? If so, you would have accidentally changed a line like the following from:

let move = $("#" + computersMove).text();


let move = $("" + computersMove).text();

I should have said replace every instance where a “#” exists in your code which is used in the logic (not syntax).

Still very confused. Do you mean in JS? I still keep the # in HTML?

You only should change a # to “” in your code (HTML, CSS, or JavaScript) where # does not have some syntactical purpose. For example, since in the following statement, you must use the # to reference an ID of an element, you must keep that or the jQuery selector will not function as needed.

let move = $("#" + computersMove).text();

The following use of # involves your actual logic or structure, so you would change them to “”

let turns = ["#", "#", "#", "#", "#", "#", "#", "#", "#"];

You only had to modify 5 lines of your JavaScript code and in the HTML, you only needed to change the anchor tags’ text (9 references).

Thank you very much for the great explanation. Finally clicked. How do I go about setting the buttons size to be a fixed size in CSS?

Try adding the following to your tic class.

  height: 60px;
  width: 60px;

Thanks a lot, but one more question for you. Not always does the computer go. What am I missing? Did I forget a #?

EDIT: The height and width for the cells didn’t do much either.
EDIT2: Nevermind, fixed the cells, now only have the problem with the computer’s consistency.

How do I center those moves into the middle of the cells, too?