+ 2
Can anybody tell me how to join my array to id in javascript
8 Antworten
+ 2
This is a possible way (a fast made solution based on your code):
https://code.sololearn.com/WHqBk1w2Y9bt/?ref=app
+ 2
JaScript can you explain what changes have you done and what were my faults
+ 2
The most important is this:
btn.addEventListener('click', function (e){
const id = e.target.id;
if (player1 == 1) {
btn.innerHTML = "X";
array_winnings[id] = "X";
x_win();
player1 = 0;
}
else {
btn.innerHTML = "0";
array_winnings[id] = "0";
y_win();
player1 = 1;
}
});
Here I get id of clicked button, which number will made to the index of array_winnings. And there I save the player character X or O and then call player specific win function to check if this player won sfter its move.
+ 2
JaScript Prefer giving hints for the OP to find the solution. It helps in the learning process.
+ 1
JaScript thank you
+ 1
Welcome & happy coding!
+ 1
JaScript okay thanks
+ 1
This is an Ari from W3school
https://www.w3schools.com/jsref/jsref_concat_array.asp#:~:text=Definition%20and%20Usage,not%20change%20the%20existing%20arrays.
Hope this helps.