Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. const input = ["s", "t", "a", "r", "m", "i", "n", "d"];
  2. const result = [];
  3.  
  4. function customReverse(accumulator, letter) {
  5. // Task 1: Implement this function such that it reverses the array when passing it to Array.prototype.reduce.
  6. }
  7.  
  8. function assignResult(array) {
  9. // Task 2: Above defined "const result" should hold the value of array.
  10. }
  11.  
  12. assignResult(input.reduce(customReverse, []));
  13. const testPassed = input.reverse().join("") === result.join("");
  14. // 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