Below is my code for move all characters forward by one for a given string.
ex. abc => bcd
const moveCharForward = (str) => {
str
.split('')
.map(char => String.fromCharCode(char.charCodeAt(0) + 1)).join('');
}
console.log(moveCharForward('abcd'));
when I called the method it throws undefined.
I modified the code by removing the curly brackets like below.
const moveCharForward = (str) =>
str
.split('')
.map(char => String.fromCharCode(char.charCodeAt(0) + 1)).join('');
console.log(moveCharForward('abcd')); //working correctly
Now when I called the method its working correctly.
I want to know why throws undefined when Im adding method implemetation inside the curly brackets?