Dot product of two arrays in Javascript
Posted: 13 Nov 2020, 12:26
What's an efficient way of implementing the dotProduct method (to get the Dot product [or scalar product] of two arrays) without importing any new Javascript libraries?
For example:
For example:
Code: Select all
const a = [1,2,3]
const b = [1,0,1]
const c = dotProduct(a,b) // will equal 4