JSFiddle - React, Tailwind, and code Playground

by andyshora

JavaScript

// a function to reverse a string
function reverseString(str){
    if (str===undefined) return false;
    if (str.length < 2) return str;
    
    return str.split('').reverse().join('');
}
document.write(reverseString("hello"));