A list of grouped items needs flattening, while a list of phrases needs splitting into words. Run flat() and flatMap() in script.js and compare the Console results.
Some arrays contain arrays, and sometimes each string needs to turn into multiple pieces. flat() and flatMap() help with those two related problems.
const supplyBins = [["paper", "pens"], ["tape"]];
const sessions = ["morning workshop", "evening lab"];
console.log(supplyBins.flat());
console.log(sessions.flatMap((session) => session.split(" ")));
splitWords by using flatMap() to split ["hello world", "js"] on spaces; the supplied probe prints both arrays.Use flat() to collapse one level of nested arrays.
Use flatMap() with split(' ') to turn phrases into words.