I need some assistance understanding why my function is consistently returning undefined.
The desired output involves reversing each word in a string that has more than 4 characters.
As a bit of a JavaScript beginner, this issue has been quite baffling for me! 😅
Your help is greatly appreciated!
const reverseString = (input) => {
input = input.split(' '); //convert to array
input = input.map(function(word){
if (word.length > 4) {
return word.split('').reverse().join('');
} else {
return word;
}
});
return console.log(input.join(' '));
}
reverseString('Hello World thank you so much');