Tic Tac Toe help - how to remove hashtags?

Tic Tac Toe help - how to remove hashtags?
0.0 0

#1

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.


#2

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.


#4

That didn’t work unfortunately.


#5

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();

to

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


#6

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


#7

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


#8

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?


#9

Try adding the following to your tic class.

  height: 60px;
  width: 60px;

#10

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.


#11

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