Multiply matrices using functional programming aspect in JavaScript