How would I rewrite this using an arrow function?
Would forEach
be the only way?
And what would be an example of an arrow function that doesn't use
the forEach
method.
CODE
let word = 'Bloc';
const reverseString = (str) => {
let stack = [];
for (let i of str) {
stack.push(str[i]);
}
let reversed = '';
for (let i of word) {
reversed += stack.pop();
}
return reversed;
}
console.log(reverseString('Bloc'));