Array reduceRight in JavaScript

Level 3121 keystrokes

reduceRight() works like reduce() but processes the array from right to left.

JavaScript code

// Create an array of single characters
1const words = ["a", "b", "c", "d"];
// reduceRight() concatenates from right to left
// Starting with "", adds d, then c, then b, then a
2const result = words.reduceRight((acc, word) => acc + word, "");
// Output: "dcba"
3console.log(result);

Output

dcba
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • "× 10
  • ,× 5
  • ;× 3
  • (× 3
  • )× 3
  • =× 3
  • .× 2
  • [× 1
  • ]× 1
  • +× 1

More JavaScript examples at level 3

← JavaScript typing practice