Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const input = ["s", "t", "a", "r", "m", "i", "n", "d"];
- const result = [];
- function customReverse(accumulator, letter) {
- // Task 1: Implement this function such that it reverses the array when passing it to Array.prototype.reduce.
- }
- function assignResult(array) {
- // Task 2: Above defined "const result" should hold the value of array.
- }
- assignResult(input.reduce(customReverse, []));
- const testPassed = input.reverse().join("") === result.join("");
- // Bonus question: Why can't we check (result === input.reverse()) to find out whether the test has passed?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement