Passed
Push — main ( 67fbf9...b28dcd )
by LCS
02:38
created

main.js ➔ startGame   A

Complexity

Conditions 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 4
1
// This file contains the JavaScript code for client-side functionality, such as handling user interactions and making API calls.
2
3
document.addEventListener('DOMContentLoaded', () => {
4
    const startButton = document.getElementById('start-game');
5
    const scoreDisplay = document.getElementById('score');
6
    let score = 0;
7
8
    startButton.addEventListener('click', () => {
9
        score = 0;
10
        scoreDisplay.textContent = `Score: ${score}`;
11
        startGame();
12
    });
13
14
    function startGame() {
0 ignored issues
show
Bug introduced by
The function startGame is declared conditionally. This is not supported by all runtimes. Consider moving it to root scope or using var startGame = function() { /* ... */ }; instead.
Loading history...
15
        // Game logic goes here
16
        // Example: Increment score every second
17
        setInterval(() => {
18
            score++;
19
            scoreDisplay.textContent = `Score: ${score}`;
20
        }, 1000);
21
    }
22
});