# ReferenceError return when attempting to set score - Dojo Course example

**URL:** <https://club.ministryoftesting.com/t/referenceerror-return-when-attempting-to-set-score-dojo-course-example/27339>\
**Category:** Discussions\
**Tags:** javascript, javascript-intro\
**Created:** [16 July 2019 13:56 UTC](https://club.ministryoftesting.com/t/referenceerror-return-when-attempting-to-set-score-dojo-course-example/27339 "2019-07-16T13:56:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwinteringham](https://sea2.discourse-cdn.com/flex020/user_avatar/club.ministryoftesting.com/mwinteringham/32/9023_2.png) [@mwinteringham](https://club.ministryoftesting.com/u/mwinteringham)\
**Post date:** [16 July 2019 13:56 UTC](https://club.ministryoftesting.com/t/referenceerror-return-when-attempting-to-set-score-dojo-course-example/27339/1 "2019-07-16T13:56:27Z")

</div>

I’ve run into an issue where when I attempt to add some points to my score I get the following error:

```auto
/Users/mark/Desktop/dice-game.js:39
        score = this.score + points;
              ^

    ReferenceError: score is not defined
        at Player.addToScore (/Users/mark/Desktop/dice-game.js:39:15)
        at rollDice (/Users/mark/Desktop/dice-game.js:14:16)
        at Object.<anonymous> (/Users/mark/Desktop/dice-game.js:50:17)
        at Module._compile (internal/modules/cjs/loader.js:776:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
        at Module.load (internal/modules/cjs/loader.js:653:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
        at Function.Module._load (internal/modules/cjs/loader.js:585:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
        at startup (internal/bootstrap/node.js:283:19)

```

This occurs when I attempt to call the function to add 10 points `player.addToScore(10);`. The code for my player can be found below:

```auto
class Player{
    constructor (name) {
        this.name = name;
        this.score = 0;
    }
  
    addToScore(points) {
        score = this.score + points;
    }

    getScore() {
        return this.score;
    };
}
```
