 # Accessing the digits of a number in JavaScript

Let now we store not a number in quotes in a variable, but just a number. In this case, an attempt to access its individual character will return `undefined`, since such an access only works for strings:

```let test = 12345; alert(test); // shows undefined```

let's convert our number to a string to solve the problem:

```let test = String(12345); // string alert(test); // shows '1' - everything works```

Suppose now we want to find the sum of the first two digits:

```let test = String(12345); // string alert(test + test); // shows '12' - concatenates like strings```

Let's add the function `Number` so that the characters are summed as numbers:

```let test = String(12345); // string alert(Number(test) + Number(test)); // shows 3```

I remind you that a problem of this kind will arise only with summation. When multiplying, for example, conversion to numbers can be omitted:

```let test = String(12345); // string alert(test * test); // shows 6```

The number given is `12345`. Find the sum of the digits of this number.

The number given is `12345`. Find the product of the digits of this number.

The number given is `12345`. Rearrange the digits of this number in reverse order.