Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reverse string in js

let a = "foo";

// function for reversing a string
function reverseString(str) {
  return str.split("").reverse().join("");
}

console.log(a); // "foo"

let b = reverseString(a);
console.log(b); // "oof"
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #reverse #string #js
ADD COMMENT
Topic
Name
4+6 =