# Multiply an array with a number

**URL:** <https://discourse.processing.org/t/multiply-an-array-with-a-number/30778>\
**Category:** Beginners\
**Created:** [June 18, 2021, 1:01pm UTC](https://discourse.processing.org/t/multiply-an-array-with-a-number/30778 "2021-06-18T13:01:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sayochi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sayochi/32/15126_2.png) [@Sayochi](https://discourse.processing.org/u/Sayochi)\
**Post date:** [June 18, 2021, 1:01pm UTC](https://discourse.processing.org/t/multiply-an-array-with-a-number/30778/1 "2021-06-18T13:01:22Z")

</div>

I need to multiply a float array with a float value without looping over every item. I checked internet a bit and tried some stuff. `array.map(number);` looks okay to me but Im getting an error:  
`cannot invoke map(float) on the array type float[]`  
looks like i need another array to multiply it with but I dont want to loop to create another array.

im beginner to processing.js any possible solution is appreciated

edit: just checked it doesnt let me multiply(scale) float[] with float[] neither. I dont know what to do

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [June 18, 2021, 3:17pm UTC](https://discourse.processing.org/t/multiply-an-array-with-a-number/30778/2 "2021-06-18T15:17:13Z")

</div>

Hi Sayochi,

Are you trying to do it in processing.js?  
Try the following example:

```auto
var numbers = [1, 4, 9];
var doubles = numbers.map(function(num) {
  return num * 2;
}); 
// doubles é agora [2, 8, 18]. numbers ainda é [1, 4, 9]

```

Just apply it to your case.

Best regards
