repl.it
@Tyledelphia/

getAllWords

JavaScript

No description

fork
loading
main.js
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
26
27
/*function getAllWords(str) {
  let wordArray = [];
  let words = str.split(' ')
  for (let i = 0; i < str.length; i++) {
     var splits = words[i];
     wordArray.push(splits);
    }
    return wordArray;
  }
  //return wordArray.push(splitUp);return words[i]
getAllWords('The quick brown fox jumps over the lazy dog.')
*/

function getAllWords(str) {
  let wordArray = [];
  let words = str.split(' ')
  for (let i = 0; i < str.length; i++) {
    let splits = words[i];
    wordArray.push(splits)
    }
    return wordArray;
  }

  //getAllWords('The quick brown fox jumps over the lazy dog.');
  
  var sentence = 'The quick brown fox jumps over the lazy dog.'
  console.log(sentence.[@@iterator]());
Native Browser JavaScript