46 lines
1.1 KiB
Text
46 lines
1.1 KiB
Text
var strReversed =
|
|
"---------- Ice and Fire ------------\n
|
|
fire, in end will world the say Some
|
|
ice. in say Some
|
|
desire of tasted I've what From
|
|
fire. favor who those with hold I
|
|
\n... elided paragraph last ...\n
|
|
Frost Robert -----------------------";
|
|
|
|
function reverseString(s) {
|
|
return s.split('\n').map(
|
|
function (line) {
|
|
return line.split().reverse().join(' ');
|
|
}
|
|
).join('\n');
|
|
}
|
|
|
|
;reverseString('Hey you, Bub!');
|
|
;strReversed;
|
|
;reverseString(strReversed);
|
|
|
|
/*
|
|
=!EXPECTSTART!=
|
|
reverseString('Hey you, Bub!') ==> Bub! you, Hey
|
|
strReversed ==> ---------- Ice and Fire ------------
|
|
|
|
fire, in end will world the say Some
|
|
ice. in say Some
|
|
desire of tasted I've what From
|
|
fire. favor who those with hold I
|
|
|
|
... elided paragraph last ...
|
|
|
|
Frost Robert -----------------------
|
|
reverseString(strReversed) ==> ------------ Fire and Ice ----------
|
|
|
|
Some say the world will end in fire,
|
|
Some say in ice.
|
|
From what I've tasted of desire
|
|
I hold with those who favor fire.
|
|
|
|
... last paragraph elided ...
|
|
|
|
----------------------- Robert Frost
|
|
=!EXPECTEND!=
|
|
*/
|