# Variable produces 1111 instead of 4

**URL:** <https://forum.kirupa.com/t/variable-produces-1111-instead-of-4/649110>\
**Category:** web dev\
**Created:** [September 29, 2021, 4:19pm UTC](https://forum.kirupa.com/t/variable-produces-1111-instead-of-4/649110 "2021-09-29T16:19:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylviaonahighway](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sylviaonahighway/32/15537_2.png) [@sylviaonahighway](https://forum.kirupa.com/u/sylviaonahighway)\
**Post date:** [September 29, 2021, 4:19pm UTC](https://forum.kirupa.com/t/variable-produces-1111-instead-of-4/649110/1 "2021-09-29T16:19:02Z")

</div>

real sorry if the title sucks.

So my deal here is that I’m making a cookie clicker wannabe (just to see if i can tbh) and I’m having an issue with freaking counting.

So I have code that is like this.  
on(release){  
var licks:Number = licks + 1;  
}

And instead of making a number like 4 it makes 1111. Please help with this if you can find an answer, I don’t actually know how to program.

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [September 29, 2021, 7:00pm UTC](https://forum.kirupa.com/t/variable-produces-1111-instead-of-4/649110/2 "2021-09-29T19:00:39Z")

</div>

This usually means you’ve got a string mixed up in there somewhere. The reason this happens is because both strings and numbers use the `+` operator. Numbers use it to add numbers together whereas strings use it for concatenation.

```
1 + 2 = 3 // numbers
"hell" + "o" = "hello" // strings

```

When you use + with strings that are themselves numbers or a combination of strings and numbers, the behavior of `+` will be to concatenate as strings

```
"1" + "1" = "11" // strings as numbers
"1" + 1 = "11" // strings and numbers

```

So if you’re using `+` and getting “1111” instead of 4, then its most likely because you have a string in there somewhere. And if you’re not sure, you can force your values to be numbers by using `Number()` to convert them

```
var licks = "1"
licks + 1 = "11" // no conversion
Number(licks) + 1 = 2 // with conversion
```

---

<div class="post-metadata">

**Author:** ![sylviaonahighway](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sylviaonahighway/32/15537_2.png) [@sylviaonahighway](https://forum.kirupa.com/u/sylviaonahighway)\
**Post date:** [September 29, 2021, 8:35pm UTC](https://forum.kirupa.com/t/variable-produces-1111-instead-of-4/649110/3 "2021-09-29T20:35:01Z")

</div>

thank you so much

ALSO i will be puiblishing this project so would you like a credit?

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [September 29, 2021, 9:08pm UTC](https://forum.kirupa.com/t/variable-produces-1111-instead-of-4/649110/4 "2021-09-29T21:08:19Z")

</div>

Welcome! And no credit is necessary 😉
