Which two assert statements are valid tests for the function?

A developer needs to test this function:

01const sum3 = (arr) => (

02if (!arr.length) return 0,

03if (arr.length === 1) return arr[0],

04if (arr.length === 2) return arr[0]+ arr[1],

05 return arr[0] + arr[1] + arr[2],

06 );

Which two assert statements are valid tests for the function?

Choose 2 answers
A . console.assert(sum3(1, ‘2’)) == 12);
B . console.assert(sum3(0)) == 0);
C . console.assert(sum3(-3, 2 )) == -1);
D . console.assert(sum3(‘hello’, 2, 3, 4)) === NaN);

Answer: A,C

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments