JSFiddle - React, Tailwind, and code Playground

by fakeguybrushthreepwood

JavaScript

var str="Quarter Pounder";
document.writeln("Reverse order of words using split() function on the string '"+str+"' with a space:");
document.writeln("<br>");
var splitStr=str.split(" ");
document.writeln(splitStr[1]+" "+splitStr[0]);
document.writeln("<br><br>");

var str="Fillet-O-Fish";
document.writeln("Reverse order of words using split() function on the string '"+str+"' with a dash:");
var str="Fillet-O-Fish";
document.writeln("<br>");
var splitStr=str.split("-");
document.writeln(splitStr[2]+"-"+splitStr[1]+"-"+splitStr[0]);
document.writeln("<br>");