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

src/public/scripts/main.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 20
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
mnd 0
bc 0
fnc 4
dl 0
loc 20
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A main.js ➔ startGame 0 8 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
});