forked from iDTech-Neha/iDTech_JavaScript_Coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreating_sentences.js
More file actions
25 lines (21 loc) · 854 Bytes
/
creating_sentences.js
File metadata and controls
25 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// TODO: Create an array variable called "words" with the following elements: 'This', 'is', 'JavaScript', 'Coding!'
// YOUR CODE GOES HERE
var words = ["This","is","JavaScript","Coding!"];
// TODO: Create an empty string variable called "sentence".
// YOUR CODE GOES HERE
var sentence = [];
// TODO:
// 1. Create a function called "createSentence" that takes an array as an argument.
// 2. In the function use a for loop to iterate through each word element of the array.
// 3. Add each word to the "sentence" variable.
// 4. Return the "sentence".
// YOUR CODE GOES HERE
function createSentence(words){
for (let i = 0; i <= words.length - 1; i++){
sentence += words[i] + " ";
}
return sentence;
}
// TODO: Call the function "createSentence" using the console.log method.
// YOUR CODE GOES HERE
console.log(createSentence(words));