Consider the following code (https://github.com/PacktPublishing/Hands-on-JavaScript-for-Python-Developers/tree/master/chapter-5/matrix/starter-code):
const a = [1, 3, 5, 7, 9]
const b = [2, 5, 7, 9, 14]
// compute the products of each permutation for efficient retrieval
const products = { }
// ...
const getProducts = function(a,b) {
// make an efficient means of retrieval
// ...
}
// bonus: get an arbitrary key/value pair. If nonexistent, compute it and store it.
So, what's the solution within the paradigm of using an object? Let's take a look, break it down, and then reverse-engineer our use of objects as a data store (spoiler alert: have you heard of NoSQL?).