# Add two single digits from an array into a double digit

Get help using Construct 2

### » Tue Apr 07, 2015 2:15 pm

Hi guys,

How do I add two single digit numbers from an array into a single double digit or more number? For example, array 0 = 5, array 1 = 2, and I want to get the value 52.

I thought the code below would work, but it didn't.

(array.at(0)) & (array.at(1))

I would think it is something close to this, and I am missing something in the syntax.
B
32
S
14
G
27
Posts: 673
Reputation: 17,321

### » Tue Apr 07, 2015 2:25 pm

If you multiply the first number by 10 you could just add them up..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

### » Tue Apr 07, 2015 2:28 pm

The & operator is a bit touchy. Used with numbers, it acts as a logical AND. You probably should convert your array entry to strings using the str() function so & actually acts as a concatenation operator again.

str(array.at(0)) & str(array.at(1))
B
51
S
19
G
19
Posts: 860
Reputation: 14,653

### » Wed Apr 08, 2015 2:54 am

@LittleStain, haha that is so devious, it is almost evil!

@Magistross, thank you! That worked perfectly!
B
32
S
14
G
27
Posts: 673
Reputation: 17,321