String reversal using charat and length property

We can reverse a string by using charat and length property of string functions in JavaScript. By using length property we will find out the total length of the string and then we will use one for loop we will print one by one character from last point using charat function.

Here is the code

<script type="text/javascript">

var my_str="Welcome to"

var i=my_str.length;

for (var x = i; x >=0; x--)



Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net



    david bandel


    note. the reason it's best to use str.charAt(x) rather than str[x] is that internet explorer doesn't support accessing characters of a string with array notation.


    this code but with Array ...???


    Write a JavaScript code that asks the user to enter a sentence in lowercase and it will display it in UPPERCASE. For example the user enters the sentence "javascript is beautiful", and the program displays "JAVASCRIPT IS BEAUTIFUL". (Use Arrays) solution !!!??....


    @esso it is really easy in an array form.
    function arrayReverse(){
    var str = ["esso","peso"];
    var arraylength = str.length;//u can use to string also.
    for(var i = arraylength-1; i>=0; i--){
    document.getElementById("here").innerHTML += str[i]+",";
    don't forget to define <body onload="arrayReverse();"><p id="here"></p> on your HTML page.
    uppercase and lowercase are as simple as those above. try to do research and it will also a best way to learn more n perfect.. hope my comments are helpful to you!
    jacob jackson mutoya


    how to code html code on revering a string in javascript

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer