Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Creating Sentences Activity

For this assignment, you’ll create a program that turns array elements into a sentence. You should create a function that takes an array of words, as an argument. Your function should loop through the array and add each element into an empty string. The function should return a sentence as its final output. To make this program, you’ll use your programming skills to create an array, declare a function, and use a for loop.

Tasks

Follow the steps below to develop your program:

Create an array variable called "words" with the following elements: 'This', 'is', 'JavaScript', 'Coding!' Create an empty string variable called "sentence". Create a function called "createSentence" that takes an array as an argument. In the function use a for loop to iterate through each word element of the array. Add each word to the "sentence" variable. Hint: Try using the += symbol to add each word to the sentence variable. For example, sum = sum + 2 can be written as sum += 2. Return the "sentence". Call the function "createSentence" using the console.log method.