Javascript String reverse()

Description

Javascript String reverse()


String.prototype.reverse = function(){
  return [...this].reduceRight((rev, cur) => {
   return rev + cur;
  }, '');//from  ww w  . j a v a2  s.co m
};

var z = "dog".reverse();
console.log('z:', z);

Javascript String reverse()

// Add a reverse function to the String prototype

String.prototype.reverse = function() {
  return this.split('').reverse().join('');
};

Javascript String reverse()

let testString = 'hello';
let expectedString = 'olleh';

String.prototype.reverse=function(){
  return this.split("").reverse().join("");
}

console.log(testString.reverse() === expectedString);

Javascript String reverse()

String.prototype.reverse = function () {
  s = this;//w  ww .j  a va  2  s  .co  m
  var i = s.length,
      o = '';
  while (i > 0) {
    o += s.substring(i - 1, i);
    i--;
  }
  return o;
}

Javascript String reverse()

String.prototype.reverse = function() {
  var s = "";
  for (var i = this.length - 1; i >= 0; i--) {
    s += this[i];/*from  w w w .jav a  2 s.c om*/
  }
  
  return s;
};

Javascript String reverse()

String.prototype.reverse = function(){
  return this.split('').reverse().join('')
};

console.log('Hello, World!'.reverse());

Javascript String reverse()

String.prototype.reverse = function() {

    return Array.prototype.reverse.apply(this.split('')).join('');

};

Javascript String reverse()

String.prototype.reverse = function() {
  return this.split('').reverse().join('');
};

"string".reverse(); //gnirts

Javascript String reverse()

String.prototype.reverse = function() {
    var s = "";
    var i = this.length;
    while (i>0) {
        s += this.substring(i-1,i);/*from  ww  w  .ja  v  a2s  .  c  om*/
        i--;
    }
    return s;
}

var string = "Patrick"
string.reverse()

Javascript String reverse()

String.prototype.reverse = function() {
  var result;/*from  ww  w . j  a  v a 2 s  .  com*/
  for (var i = this.length - 1; i >= 0; i--) {
    result += this.charAt(i);
  }
  return result;
}

module.exports = String;

Javascript String reverse()

String.prototype.reverse = function(){
  var result = [];
  var values =  this.split('');
  for(var cont = 0; cont < values.length; cont++){
    result.unshift(values[cont]);/*from  w  w  w  . j  a  v  a  2  s . c o m*/
  }
  return result.join('');
}

Javascript String reverse()

String.prototype.reverse = function() {
   var o = '',
       i = this.length;/*from   w  w  w .  j  a  v  a2 s.co m*/
   while (i--) {
      o += this.charAt(i);
   }
   return o;
};

Javascript String reverse()

String.prototype.reverse = function() {
    var rev = '';
    for (var i = this.length - 1; i >= 0; i--) {
        rev += this[i];//from   ww  w . ja v a  2s .c o m
    }
    return rev;
};

Javascript String reverse()

/*/*w  w w .  jav  a 2  s.  co  m*/
    Strings 00. Reverse a String - Enter a string and the program will reverse it and print it out.
    Solved it first using the classic split - reverse - join process.
*/

String.prototype.reverse = function () {
    "use strict";

    var i,
        r;

    for (i = this.length - 1, r = ''; i >= 0; r += this[i--]) {}
    return r;
};

this.console.log("stringExample".reverse());

Javascript String reverse()

String.prototype.reverse = function() {
  return this.split('').reverse().join('');
};

var num = 11;//from  w  ww  .jav  a2  s  . c  o m

while(true) {
  if((num.toString() == num.toString().reverse()) && (num.toString(2) == num.toString(2).reverse()) && (num.toString(8) == num.toString(8).reverse())){
    break;
  }
  num += 2;
}

console.log(num);



PreviousNext

Related