Question: Trying to print the value in y for the number of times that shows in x.

How should I modify the following syntax to achieve the expected output?

```
x = 5
y = ['a', 'b']
z = []

for num in list(range(x)):
    for idx, num1 in enumerate(y):
        z.append(num1)

```

Output based on above:

```
['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b']

```

Expected output:

```
['a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'b']

```

Answer: 
The first reduce is working as intended. As it is already reduced it will not perform anything.

To be more explicit, the callback you pass to the `reduce()` method will be called on each element of the array, but as your array is empty, there it will not be called.

See <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce>.
As mentioned in the docs:

> 
> The reduce() method executes a user-supplied “reducer” callback function on each element of the array
> 
> 
> 

If there are no elements the callback won't run

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce>