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: 
If the array is empty, `shortestElement` is still `Infinity`, since the loop never runs and you don't reassign it.

You can simply check for an empty array at the beginning.

Another improvement is to initialize `shortestElement` from the first element, and then loop starting from the second element.

You should also check for a zero-length element before checking if the length is less than `shortestElement`, since `0` will always be less and you won't ever get to the `else if` (unless there are two zero-length elements in the array).

```js
function getLengthOfShortestElement(arr) {
  if (arr.length == 0) {
    return 0;
  }

  var shortestElement = arr[0].length;

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

var output = getLengthOfShortestElement([]);
console.log(output);
```
You should move the `arr.length === 0` outside of the loop, or else it will never run.
Try this instead

```
function getLengthOfShortestElement(arr) {

  var shortestElement = Infinity;

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

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

```