Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Example: 'abc def' --> 'fed cba'
- */
- function reverseAll(array) {
- }
- /*
- * Example: 'abc def' --> 'cba fed'
- */
- function reverseWords(array) {
- }
- /***************************/
- /***************************/
- /* DO NOT CHANGE DOWN HERE */
- /***************************/
- /***************************/
- function solve(text) {
- console.log("Reversing string: " + text);
- var reversedAll = text.split('');
- reverseAll(reversedAll);
- console.log("Result after reversing all: " + reversedAll.join(''));
- var reversedWords = text.split('');
- reverseWords(reversedWords);
- console.log("Result after reversing the words: " + reversedWords.join(''));
- console.log();
- }
- solve("abc def");
- solve("This is a sentence I want to reverse");
Advertisement
Add Comment
Please, Sign In to add comment