I'm trying to figure out how to return a sentence where I have a list of items and I have to separate them with a ", ". However, if the array only contains one item, you would just return the word with no comma and if there is two words, then you would return one comma after the first word and not the last.
var conceptList = ['apple', 'orange', 'banana'];
var concepts = joinList(conceptList);
function joinList() {
for (var i = 0; i < conceptList.length; i++) {
if (conceptList.length) {
conceptList[i];
}
return conceptList;
}
}
console.log("Today I learned about " + concepts + ".");