Without using the split reverse and join functions, how would one do such a thing?
The Problem Given: Reverse the words in a string Sample Input: "Hello World" Sample Output: "World Hello"
<script>
var newString = "";
var theString = prompt("Enter a Phrase that you would like to reverse (Ex. Hello world)");
newString = theString.split(" ").reverse().join(" ")
document.write(newString);
</script>
I am able to make it using the inbuilt methods. But the question asks to use only use
- Arrays
- Substring
- charAt()
So how would I go about this?