DEV Community

Cover image for My First Thing! Combining JavaScript/HTML/CSS
Ethan Goddard
Ethan Goddard

Posted on • Updated on

My First Thing! Combining JavaScript/HTML/CSS

I had a personal breakthrough the other day on my software developer journey, I built my first interactive webpage using HTML, the Bulma CSS framework, and JavaScript!

It was the first time I've fully combined all three technologies to build something that is actually usable and I did it all on my own without following a tutorial.

The thrill of figuring out the logic and watching it come to life was very powerful and motivating. If anyone out there doubts they can become a developer, DON'T! It can happen if we just keep trying and learning!

ScoreKeeper Demo


const playerOneButton = document.querySelector('#p1');
const playerTwoButton = document.querySelector('#p2');
const resetButton = document.querySelector('#reset');
const playerOneDisplay = document.querySelector('#p1Score');
const playerTwoDisplay = document.querySelector('#p2Score');
const roundLimitSelector = document.querySelector('#playToAmount')

let playerOneScore = 0;
let playerTwoScore = 0;
let roundLimit = 6;

roundLimitSelector.addEventListener('change', function(){
    roundLimit = parseInt(this.value);

playerOneButton.addEventListener('click', function(){
    playerOneScore += 1;
    playerOneDisplay.textContent = playerOneScore;
    if (playerOneScore === roundLimit){ = 'green'; = 'red';
        playerOneButton.disabled = true;
        playerTwoButton.disabled = true;

playerTwoButton.addEventListener('click', function(){
    playerTwoScore += 1;
    playerTwoDisplay.textContent = playerTwoScore;
    if (playerTwoScore === roundLimit){ = 'red'; = 'green';
        playerOneButton.disabled = true;
        playerTwoButton.disabled = true;

resetButton.addEventListener('click', function(){
    playerOneDisplay.textContent = 0;
    playerTwoDisplay.textContent = 0; = 'black'; = 'black';
    playerOneScore = 0;
    playerTwoScore = 0;
    playerOneButton.disabled = false;
    playerTwoButton.disabled = false;
Enter fullscreen mode Exit fullscreen mode


<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Score Keeper</title>
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="Score_Keeper.css">

    <div class='columns'>
        <div class='column'></div>
        <div class='column card'>
                <img class='card-image' src=""
                    alt="Ping Pong Paddles">
                <p class='has-text-weight-bold box'>Ping Pong Score Keeper</p>
            <div class='card-content'>
                <p class='has-text-weight-bold is-size-2 title'><span id="p1Score">0</span> to <span
                <p class='subtitle'>Use the buttons below to keep score.</p>
            <div class='card-content'>
                <label for="playToAmount" class='has-text-weight-bold is-size-5'>Playing To:</label>
                <select name="counter" id="playToAmount">
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                <div class='level-item has-text-centered card-footer'>
                    <button class='button is-primary card-footer-item' id='p1'>+1 Player One</button>
                    <button class='button is-info card-footer-item' id='p2'>+1 Player Two</button>
                    <button class='button is-danger card-footer-item' id='reset'>Reset</button>
        <div class='column'></div>

    <script src="Score_Keeper.js"></script>

Enter fullscreen mode Exit fullscreen mode


.columns {
    padding-top: 50px;
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed the read!

Feel free to follow me on GitHub, LinkedIn and DEV for more!

Discussion (0)