> For the complete documentation index, see [llms.txt](https://demirels-organization.gitbook.io/javascript-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demirels-organization.gitbook.io/javascript-tutorial/arrow-functions/rhythm-game-example.md).

# Rhythm Game Example

Here's an example of how arrow functions can be used to handle button presses:

```javascript
document.getElementById("leftButton").addEventListener("click", () => {
  player.moveLeft();
});
document.getElementById("rightButton").addEventListener("click", () => {
  player.moveRight();
});
```

In this example, arrow functions are passed as callbacks to the `addEventListener` method. When the left button or the right button is clicked, the corresponding arrow function is invoked, which calls the `moveLeft()` or `moveRight()` method on the `player` object.

Another example, a function that handle the score and accuracy of the player

```javascript
let score = 0;
let accuracy = 0;
let noteChecker = (note) => {
  if(note.status === "hit") {
    score += 100;
    accuracy += 1;
  } else {
    score -= 50;
  }
  updateScore();
  updateAccuracy();
}
```

In this example, the arrow function `noteChecker` is used to check if a note is hit or missed by the player, and updates the score and accuracy accordingly. The `updateScore()` and `updateAccuracy()` are also functions that would update the score and accuracy on the screen.
