Question: I have an array of arrays with sentences in each element. I want to end up with one single array with each word split up by spaces and then get the length of the whole array

I know I need to loop through the array and then apply split but is there a better way?

```js
const temp2 = [
  ['this is an array'],
  ['this is a scentence'],
  ['I love stackoverflow']
]
console.log(
  temp2[0][0].split(' ').length // 3 words
)  
```

Answer: 
* Use [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) to flatten the nested array into a single array or words
* Use [Array.prototype.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join) to convert the Array to a string joined by whitespace.
* [Split the string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) by one or more spaces

```js
const temp2 = [
  ['this is an array'],
  ['this is a scentence'],
  ['i love stackoverfloe']
]

const arr = temp2.flat().join(" ").split(/ +/);
console.log(arr);  // or use: arr.length
```
try this, maybe this is what you want:

```js
const temp2 = [
  ['this is an array'],
  ['this is a scentence'],
  ['i love stackoverfloe']
]

let res = temp2.reduce((prev, next) => {
    const tempArr = next[0].split(" ")
    for (let i = 0; len = tempArr.length, i < len; i ++) {
        prev.push(tempArr[i])
    }
    return prev
}, [])

console.log("res", res)
console.log("res.length", res.length)

```