Javascript String reverse comma separated String

Description

Javascript String reverse comma separated String

let values = "Apples,Oranges,Bananas";

function splitAndReverseText(csv) {
    let parts = csv.split(",");
    parts.reverse();/*from w ww  . ja  v  a2s.  co m*/

    let reversedString = parts.join(",");

    console.log(reversedString);
}

splitAndReverseText(values);



PreviousNext

Related