Bad Data explainer

Aim of the puzzle: Use console.log() to debug code that is not working as intended.
Walk through of solution: When a function or a block of code isn’t working properly, it can be useful to add console.log() statements to take a closer look at what is going on.

In this puzzle, the produce array is imported from additional code. The getLength() function will iterate through this array and print the length of each string in the array to the console.

There is a problem, however. For one of the items in the array, the function is printing a length of 0.

To figure out what’s going on, let’s use a console.log() to take a look at each string in the produce array.

To complete the puzzle, add a console.log() to the for loop, and use the looping variable as an argument. This will print each string in the produce array to the console, one at a time.

When this has been done, running the code will show that one of the items in the produce array is an empty string, which is the source of the problem!

Sample code solution:

import { produce } from '';

function getLength(words) {
    for (let word of words) {
        console.log(word.length + ' characters long');


Javascript Concepts: Debugging, console.log(), For Loops, .length