# Add two numeric values in pre-request script

**URL:** <https://community.postman.com/t/add-two-numeric-values-in-pre-request-script/30392>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [December 4, 2021, 9:26pm UTC](https://community.postman.com/t/add-two-numeric-values-in-pre-request-script/30392 "2021-12-04T21:26:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajd84](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@ajd84](https://community.postman.com/u/ajd84)\
**Post date:** [December 4, 2021, 9:26pm UTC](https://community.postman.com/t/add-two-numeric-values-in-pre-request-script/30392/1 "2021-12-04T21:26:53Z")

</div>

First of all, thanks to everyone who posts in the community, as a relative newbie I have found it really useful to get to know Postman and all the responses are super friendly and helpful.

But I’m stuck on something and I know it should not be that hard.

In a pre-request Script I want to set two random numeric variables between 0-100.99 \< done  
But I then want the average of these two values  
My plan was to add value01+value02 = sum  
then sum/2 = average  
the average part works with one value,  
the bit I can’t seem to figure out is how to add two values!  
if value01 = 50.29 and value02 = 20.10 for example, I want sum = 70.39  
but I get 50.2920.10

I have tried math, calculate, everything I can think of.

here is my example

```auto
const first1 =("first1", _.random(0,100))
const second1=("second1", _.random(0,99))
const value01 = first1 +"."+ second1
const first2 =("first2", _.random(0,100))
const second2 =("second2", _.random(0,99))
const value02 = first2 +"."+ second2
let sum = value01 + value02
let average = sum / 2
pm.globals.set("value01",value01);
pm.globals.set("value02",value02);
pm.globals.set('sum', sum);
pm.globals.set('average', average);

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/8/8a2cca0badf27505b5c1bfcd23fc0d0ded875409.png)

as I say, I’m a newbie so any help or advice is much appreciated

---

<div class="post-metadata">

**Author:** ![ajd84](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@ajd84](https://community.postman.com/u/ajd84)\
**Post date:** [December 6, 2021, 4:32pm UTC](https://community.postman.com/t/add-two-numeric-values-in-pre-request-script/30392/2 "2021-12-06T16:32:51Z")

</div>

figured it out while the post was been reviewed.

```auto
let sum = +value01 + +value02

```

I needed the + before the value to declare it as a number
