debut TP2
This commit is contained in:
10
src/exercises/multiplyArrays2/index.ts
Normal file
10
src/exercises/multiplyArrays2/index.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export function multiplyArrays(arr1: number[], arr2: number[]): number[] {
|
||||
const isSameLength = arr1.length === arr2.length;
|
||||
|
||||
if (!isSameLength) throw new Error("Arrays must be the same length");
|
||||
|
||||
const isOneEmpty = arr1.length === 0 || arr2.length === 0;
|
||||
if (isOneEmpty) throw new Error("Arrays must not be empty");
|
||||
|
||||
return arr1.map((num, index) => num * arr2[index]);
|
||||
}
|
Reference in New Issue
Block a user