Contact: aviboots(AT)netvision.net.il
32,304 questions
42,479 answers
573 users
function ReverseString(s) { let rev = ''; for (let i = s.length - 1; i >= 0; i--) rev += s[i]; return rev; } let s = "JavaScript C C++ C# Java"; console.log(ReverseString(s)); /* run: avaJ #C ++C C tpircSavaJ */
function ReverseString(s) { let rev = []; for (let i = 0, len = s.length; i <= len; i++) rev.push(s.charAt(len - i)); return rev.join(''); } let s = "JavaScript C C++ C# Java"; console.log(ReverseString(s)); /* run: avaJ #C ++C C tpircSavaJ */
function ReverseString(s) { return s.split('').reverse().join(''); } let s = "JavaScript C C++ C# Java"; console.log(ReverseString(s)); /* run: avaJ #C ++C C tpircSavaJ */
function ReverseString(s) { for (let i = s.length - 1, rev = ''; i >= 0; rev += s[i--]) { } return rev; } let s = "JavaScript C C++ C# Java"; console.log(ReverseString(s)); /* run: avaJ #C ++C C tpircSavaJ */
function ReverseString(s) { s = s.split(''); let len = s.length; let middle = Math.floor(len / 2) - 1; for (let i = 0; i <= middle; i++) { let tmp = s[len - i - 1]; s[len - i - 1] = s[i]; s[i] = tmp; } return s.join(''); } let s = "JavaScript C C++ C# Java"; console.log(ReverseString(s)); /* run: avaJ #C ++C C tpircSavaJ */
function ReverseString(s) { return [...s].reverse().join(''); } let s = "JavaScript C C++ C# Java"; console.log(ReverseString(s)); /* run: avaJ #C ++C C tpircSavaJ */