SQL and Map-Reduce-Filter
Explore how to convert SQL queries into JavaScript by applying map, reduce, and filter functions without loops or if statements. Understand the process of joining data arrays, counting items, and summing values, all while practicing modern ES6 coding techniques useful for job interviews.
We'll cover the following...
We'll cover the following...
Exercise:
Suppose the following tables are given in the form of arrays of objects:
Translate the following SQL query using map, reduce, and filter:
You are not allowed to use loops, if statements, logical operators, or the ternary operator.
Solution:
We need to list all character names and the sum of the value of their items.
As characters and inventory are arrays, we can use the map, reduce, and filter. ...