Notifications
Clear all

Which two assert statements are valid tests for the function?

1 Posts
1 Users
0 Likes
119 Views
(@ripaharris)
Posts: 737
Noble Member
Topic starter
 

A developer needs to test this function:

01 const sum3 = (arr) => (

02 if (!arr.length) return 0,

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

04 if (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);

Show Answer Hide Answer

Suggested Answer: A,C
 
Posted : 13/12/2022 11:15 am

Latest Salesforce JavaScript Developer I Dumps Valid Version

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund
Share: