Answers for "get value from string and reverse function"

0

reverse a string

//////////////////////////////////////
function reverse(str) {
  if(!str || str.length<2 || typeof str !== 'string'){
    return 'hmmm that is not good...';
  	}
  return str.split('').reverse().join('');
}

//////////////////////////////////////
function reverse(str) {
  let n = str.length;
  let s = '';
  for (let i = n - 1; i >= 0; i--) {
    s += str[i];
  }
  console.log(s);
}
reverse('Hello'); // olleH
Posted by: Guest on June-23-2021
-1

reverse a string

let t = s.chars().rev().collect::<String>();
Posted by: Guest on February-22-2021

Code answers related to "get value from string and reverse function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language