Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Strings in JavaScript have a function called <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split" rel="nofollow"><code>split()</code></a> which turn them in to Arrays. Arrays in JavaScript have a function called <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse" rel="nofollow"><code>reverse()</code></a> which reverse their order, and a function called <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join" rel="nofollow"><code>join()</code></a> which turn them back into Strings. You can combine these into:</p> <pre><code>"John Smith".split("").reverse().join("") </code></pre> <p>This returns:</p> <pre><code>"htimS nhoJ" </code></pre> <p>Also, and I don't know if this is a typo, but you can throw a <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase" rel="nofollow"><code>toLowerCase()</code></a> to get 100% of what your question is after:</p> <pre><code>"John Smith".split("").reverse().join("").toLowerCase() </code></pre> <p>returns:</p> <pre><code>"htims nhoj" </code></pre> <p>As for the question in your title, you can specify the direction of a for loop in the last argument like so:</p> <pre><code>var reversed = []; var name = "John Smith".split(""); for(var i = name.length-1; i &gt;= 0; i--) { reversed.push(name[i]); } console.log(reversed.join("")); </code></pre> <p>Which will output:</p> <pre><code>"htimS nhoJ" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload