🌐
GeeksforGeeks
geeksforgeeks.org › javascript › reverse-a-string-in-javascript
Reverse a String in JavaScript - GeeksforGeeks
reverse(): This method reverses the order of elements in the array, swapping the first element with the last, and so on. join(): This method combines all elements of the array back into a single string, using an optional separator.
Published   December 20, 2025
🌐
W3Schools
w3schools.com › jsref › jsref_reverse.asp
JavaScript Array reverse() Method
The reverse() method overwrites the original array. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make ...
🌐
freeCodeCamp
freecodecamp.org › news › how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb
Three Ways to Reverse a String in JavaScript
March 14, 2016 - The split() method splits a String object into an array of string by separating the string into sub strings. The reverse() method reverses an array in place.
🌐
Medium
medium.com › @matt.readout › string-reversal-with-javascript-bd96983ab2a7
String Reversal with JavaScript. A brief look at a couple solutions to a… | by matt readout | Medium
August 4, 2019 - By passing in an empty string '' our input string will be split on each individual character. So, if we’re calling reverse('apple'), the result of str.split('') will be the array ['a', 'p', 'p', 'l', 'e']. This is good — we can work with this!
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › reverse
Array.prototype.reverse() - JavaScript - MDN Web Docs
In other words, elements order in the array will be turned towards the direction opposite to that previously stated. To reverse the elements in an array without mutating the original array, use toReversed().
🌐
Medium
medium.com › @jsutcliffe1991 › javascript-array-method-simply-reverse-a-string-reverse-vs-toreversed-join-649e7a4f5e97
Simply Reverse a String / .reverse() vs .toReversed() / .join()
July 6, 2023 - When first dipping our toes into the possibilities of programming, learning to reverse a string is a small milestone that we all cross on our code learning journey. The task is the crux of many codewars and leetcode problems, as well as the many junior interview code questions (on the easier end of the scale..). This article breaks down a simple way to carry this out by chaining a few javascript methods. The first step is splitting the string into an array.
🌐
Inspector
inspector.dev › home › how to reverse a string in javascript – fast tips
How to reverse a string in Javascript - Fast tips - Inspector.dev
November 7, 2024 - We begin by transforming the string into an array of characters using the split() method. Then we use the reverse() method to reverse the order of the characters in the array. Finally, the array is converted back into a string using join().
🌐
Programiz
programiz.com › javascript › examples › reverse-string
JavaScript Program to Reverse a String
The string elements are reversed using the reverse() method. arrayStrings.reverse() gives ["o", "l", "l", "e", "h"].
🌐
SamanthaMing
samanthaming.com › pictorials › how-to-reverse-a-string
How to Reverse a String in JavaScript | SamanthaMing.com
In JavaScript, there is no built-in method to reverse a string. There is however, a built-in method to reverse an array.
Find elsewhere
🌐
Stack Abuse
stackabuse.com › how-to-reverse-a-string-in-javascript
How to Reverse a String in JavaScript
September 28, 2023 - The simplest way to reverse a string in JavaScript is to split a string into an array, reverse() it and join() it back into a string.
🌐
DEV Community
dev.to › onlinemsr › javascript-reverse-string-3-best-ways-to-do-it-8co
JavaScript Reverse String: 3 Best Ways To Do It - DEV Community
July 3, 2023 - The reverse() method is one of the built-in array methods. It reverses the order of the original array’s elements. To use this method in JavaScript to reverse a string first splits the string into an array of characters.
🌐
DEV Community
dev.to › swarnaliroy94 › reverse-a-string-in-javascript-e1i
Reverse a String in JavaScript - DEV Community
September 10, 2021 - The function stringReversed returns the current value adding it with the previous value, which is actually reversing the whole array characters and joining them together in a reversed way.
🌐
DEV Community
dev.to › sarah_chima › reverse-a-string-four-javascript-solutions-2nbm
Reverse a String - Four JavaScript Solutions - DEV Community
July 17, 2019 - The reverse() method reverses an array in place. The first array element becomes the last, and the last array element becomes the first. In our case though, we are working with strings.
🌐
WsCube Tech
wscubetech.com › resources › javascript › programs › reverse-string
Reverse a String in JavaScript (7 Programs)
January 20, 2026 - Learn 7 ways to reverse strings in JavaScript using efficient methods. Improve your coding skills with easy-to-understand programs and examples.
🌐
GeeksforGeeks
geeksforgeeks.org › reverse-an-array-in-javascript
Reverse an Array in JavaScript | GeeksforGeeks
January 20, 2025 - In this article, we will see how to print 1 to N using Recursion in JavaScript. What is Recursion? The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. In the recursive program, the solution to the base ... Given a string, write a recursive function that checks if the given string is a palindrome, else, not a palindrome. A string is called a palindrome if the reverse of the string is the same as the original one.
Top answer
1 of 4
1

Much simpler solution - use the below function

    function reverseArray(arr) {
       for(let idx in arr) { 
         arr[idx] = arr[idx].split('').reverse().join('');
       }
    }
    
    const sampleArr = ['ABC', 'DEF','GHI','JKL'];
    
    console.log('Before Reverse', sampleArr);
    
    reverseArray(sampleArr);
    
    console.log('After Reverse', sampleArr);

Edit:

If you don't want to change the existing array use below function

        function reverseArray(arr) {
           return arr.map(item => item.split('').reverse().join(''));
        }
        
        const sampleArr = ['ABC', 'DEF','GHI','JKL'];
        const reverseArr = reverseArray(sampleArr);
        console.log('Before Reverse', sampleArr);
        console.log('After Reverse', reverseArr);

2 of 4
0

Did you mean reverseStuff(args[y]) in your code instead of return functionReverse(args)? Because, the first one will call the reverse function for each string. The second one will probably be an error since there is no function named functionReverse in your code. Even if it existed, what you are doing is calling that function with the entire array of strings every time for the length of the array args. The missing args[y] is the main issue. Here, you are accessing the value at the yth index of the array args which, is what you wanted to do. Also, as @ASDFGerte pointed out, <= should be < since the first one will return undefined.

Also note that with the above change, the function will iterate through the array but since it returns nothing, the console.log(eachword(args)) line will print undefined. In this case, you can do the following:

// inside the for loop in eachWord
console.log(reverseStuff(args[y]);

Or, the better solution will be the following:

const args = process.argv.slice(2);
let allArr = [];
let eachWord = function (args, cb) {
  for (let y = 0; y < args.length; y++) {
      cb(reverseStuff(args[y]));
  }
};
let cb = function(reveredString) {
    // do what you want here
    // for example
    allArr.push(reveredString);
    // or just simply print
    console.log(reversedString);
};
eachWord(args, cb);

Hope this helps!

🌐
CoreUI
coreui.io › answers › how-to-reverse-a-string-in-javascript
How to reverse a string in JavaScript · CoreUI
May 18, 2026 - With over 25 years of experience ... the most straightforward and readable solution is using the combination of split(), reverse(), and join() methods to convert the string to an array, reverse it, and convert back....
🌐
ReqBin
reqbin.com › code › javascript › rgwrzonz › javascript-reverse-array-example
How do I reverse an array in JavaScript?
let array = ['JavaScript', 'Array', 'Reverse', 'Example']; let newArray = []; for(i = array.length-1; i >= 0; i--) { newArray.push(array[i]); } console.log(newArray); // output: ['Example', 'Reverse', 'Array', 'JavaScript'] How do I check if an array contains a value in JavaScript? How do I slice an array in JavaScript? How do I copy and clone an array in JavaScript? How to get the sum of an array in JavaScript? How do I concatenate an array into a string in JavaScript?
🌐
Medium
medium.com › sonyamoisset › reverse-a-string-in-javascript-a18027b8e91c
Reverse a String in JavaScript. This article is based on Free Code Camp… | by Sonya Moisset | iDevOI | Medium
November 25, 2016 - reverString("hello") should become ... sgniteerG" For this solution, you will use three methods: the String.prototype.split() method, the Array.prototype.reverse() method and the Array.prototype.join() method....