debut TP2

This commit is contained in:
2024-04-18 09:43:42 +02:00
parent a17920df41
commit e092272bd4
31 changed files with 696 additions and 37 deletions

View 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]);
}