// This test takes an array, loops through each top level index // and logs an error if the index contains an array. // Passes are tallied, and passes/fails are output at the end of the test. const flattenTest = arr => { // Define error message and initialize pass counter const errorMessage = ind => `Index ${ind} contains an array`; let passCount = 0; arr.forEach((item, ind) => { // If the item is an array, log the message if(Array.isArray(item)){ console.error(errorMessage(ind)); // If not an array, increment pass counter } else { passCount++; } }); // Log out results console.log(`${arr.length} total top level indexes.`); console.log(`${passCount} tests passed.`); console.log(`${arr.length - passCount} tests failed.`); } module.exports = flattenTest;