Advertisements

I want to create an array of numbers which gives the square of those numbers; for example I tried this but it does not work:

```
let arr = [1, 2, 30, 50, 7, 83, 670]
let n = array.map((num)=>{
return num % num
})
console.log(n)
```

### >Solution :

I can see there is a small problem in your code.

just replace ( % ) sign with ( * ) between num % num.

The code should be like this

```
let arr = [ 1, 2, 30, 50, 7, 83, 670 ]
let n = array.map((num){
return num * num
})
console.log(n).
```

The expected output should be the square of the numbers in the given array.