I am trying to take an array of strings, and using forEach return a single string containing all the array items. The directions specifically exclude using .join(), which would have been my 1st choice.
// This is a list of words
let words = ['Loops', 'are', 'a', 'great', 'way', 'to', 'find', 'elements', 'in', 'an', 'array'];
// TODO: implement this function to return a string containing all words in a paragraph.
function createParagraph(words) {
let paragraph = '';
return paragraph;
}
// Prints paragraph to console
console.log(createParagraph(words));
// don't change this line
if (typeof module !== 'undefined') {
module.exports = createParagraph;
}
I have tried:
words.forEach(words.join(' ')).push(paragraph);
join(), you can loop over the items and each time performparagraph += " " + currentWordwords.forEach(word => paragraph += word += " ");That worked! Thank you so much!