← Back to challenges

Orthogonal Vector

JavaScriptHardmathlanguage_fundamentalsvalidation

Instructions

Create a function that takes two vectors as arrays and checks if the two vectors are orthogonal or not. The return value is boolean. Two vectors a and b are orthogonal if their dot product is equal to zero.

Examples

isOrthogonal([1, 2], [2, -1]) ➞ true

isOrthogonal([3, -1], [7, 5]) ➞ false

isOrthogonal([1, 2, 0], [2, -1, 10]) ➞ true

Notes

  • The two arrays will be of same length.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Double Factorial