Html code part works well
<div class =”flex-blackjack-row-3
<table>
<tr>
<th>Wins</th>
<th>Losses</th>
<th> Draws</th>
</tr>
<tr>
<td><span id=”wins”>0</span></td>
<td><span id=”losses>0</span></td>
<td><span id=”draws>0<</span></td>
</tr>
</div>
In the Javascript code, everything else but the showScore works. showScore is not putting the score there.
function blackjackHit() {
let card = randomCard();
console.log(card);
showCard(card, YOU);
updateScore(card, YOU);
showScore(card, YOU);
}
function showScore(activePlayer) {
Document.querySelector(activePlayer[‘scoreSpan’]).textContent = activePlayer[‘score’];
You missed some brackets and used erroneous quotation marks in your code. So, you need to be careful with the syntax in HTML and Javascript, as usually, the browser digests everything you code without advice. However, you can use the developer's tools in your browser to detect some of those problems. Concerning your question, try with the code below, where those problems are corrected:
HTML
<div class ="flex-blackjack-row-3">
<table>
<tr>
<th>Wins</th>
<th>Losses</th>
<th> Draws</th>
</tr>
<tr>
<td><span id="wins">0</span></td>
<td><span id="losses">0</span></td>
<td><span id="draws">0</span></td>
</tr>
</div>
Javascript
function blackjackHit() {
let card = randomCard();
console.log(card);
showCard(card, YOU);
updateScore(card, YOU);
showScore(card, YOU);
}
function showScore(activePlayer) {
document.querySelector(activePlayer['scoreSpan']).textContent = activePlayer['score'];
}