I’ve created a quiz type of website and I was wondering how I can change my code to add the score to the tweet
<button class="tweet-score" onclick="window.location.href="window.location.href="//twitter.com/intent/tweet?text=Check%20out%20my%20score%20on%20this!%3A&url=http%3A%2F%2Fexample-quiz.com/%2F">Share your score</button>
To display the score on the results html page, I just use #score
with the CSS being as simple as:
#score{
font-size: 100px;
margin: 50px 0px;
}
Here is the JavaScript:
function showScore(){
var queryString = window.location.search
var score = new URLSearchParams(queryString).get("score")
$('#score').html(score + '/10')
}