reverse the words in a string
[WHAT]
- ] test was "reverse the words in a string"
- ] my thinking to create a solution was to use the split function on the 'space' char to create an arrary of words out of the string,
- ] then print out the array from the last item to the first item
[WHY]
- ]
[WHERE]
- ]
[WHEN]
- ]
[EXAMPLE]
- ]
let reverseWords = function(stringToReverse){
// array likely has a method to reverse the elements, but will use my own iteration
var wordArray = stringToReverse.split(' ');
var reversedString ="";
for ( i= wordArray.length, i >= 0, i--){
reversedString += wordArray[i]+' ';
}
return reversedString;
}
[HOW-TO]
- ]
[REFERENCE]
- [] src =