Question: ```
// Should equal 0 when an empty Array is entered

function getLengthOfShortestElement(arr) {

  var shortestElement = Infinity;

  for(var i=0; i < arr.length; i++) {
    if(arr[i].length < shortestElement) {
      shortestElement = arr[i].length;
    } else if (arr[i].length === 0) {
      return 0;
    } 
  }
  return shortestElement;
}

var output = getLengthOfShortestElement([]);
console.log(output);

```

Judging by the code why isn't it outputting 0? Instead it outputs Infinity..

Answer: 
The idiomatic way to accomplish what you're trying to do involves the `Array.reduce` method:

```js
function getLengthOfShortestElement(arr) {
  const toShortest = (shortest, { length: current }) => shortest < current ? shortest : current;
  const shortest = arr.reduce(toShortest, Infinity);
  return shortest === Infinity ? 0 : shortest;
}

console.log(
  getLengthOfShortestElement(['amazon', 'worm', 'lightyear']), // 4
  getLengthOfShortestElement([]) // 0
);
```
I believe it may be that you are checking arr[i].length instead of arr.length because you only check if arr[i].length is 0 and if then the function returns 0, otherwise shortestElement is still equal to infinity and is returned.