const str = 'JavaScript is awesome';
function reverseAString(str) {
return str.split('').reverse().join('');
}
console.log(`Reversed string is: ${reverseAString(str)}`);
function reverseWords(str) {
const allWords = str.split(" ")
return allWords.map(item => item.split("").reverse().join("")).join(" ")
}
const reverse = str => str.split('').reverse().join('');
reverse('hello world');
// Result: 'dlrow olleh'
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
// HazaaZOOZ - javascript - How to reverse words in javascript
function reverseInPlace(str) {
var words = [];
words = str.match(/S+/g);
var result = "";
for (var i = 0; i < words.length; i++) {
result += words[i].split('').reverse().join('') + " ";
}
return result;
}
console.log(reverseInPlace("abd fhe kdj"));
function reverseString(str) {
let strList = str.split('');
let reversed = strList.reverse();
return reversed.join('');
}
function reverseInPlace(str) {
var words = [];
words = str.match(/S+/g);
var result = "";
for (var i = 0; i < words.length; i++) {
result += words[i].split('').reverse().join('') + " ";
}
return result
}
console.log(reverseInPlace("abd fhe kdj"))
function reverse (word) {
word = word.split('.').reverse().join('.')
return word
}
word = 'i.like.this.program.very.much'
word = 'pqr.mno'
console.log(reverse(word))
const reverse = str => [...str].reverse().join``;