Valid JavaScript-Developer-I Dumps shared by ExamDiscuss.com for Helping Passing JavaScript-Developer-I Exam! ExamDiscuss.com now offer the newest JavaScript-Developer-I exam dumps, the ExamDiscuss.com JavaScript-Developer-I exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com JavaScript-Developer-I dumps with Test Engine here:
Access JavaScript-Developer-I Dumps Premium Version
(224 Q&As Dumps, 35%OFF Special Discount Code: freecram)
Recent Comments (The most recent comments are at the top.)
Option A, B, C are correct.
try the below code: in console.
const sum3 = (arr) => {
if(!arr.length)
{return 0;}
if(arr.length === 1){ return arr[0]
}
if(arr.length === 2) {return arr[0]+ arr[1];}
return arr[0] + arr[1] + arr[2];
}
console.log(sum3([1, '2']));//console.assert(sum3(1, '2')) == 12);
console.log(sum3(['hello', 2, 3, 4]));// console.assert(sum3('hello', 2, 3, 4)) === NaN);
console.log(sum3([0]));//console.assert(sum3(0)) == 0);
console.log(sum3([-3, 2]));//console.assert(sum3(-3, 2 )) == -1);
The correct answers are A and B:
A. console.assert(sum3([-3, 2]) == -1);
B. console.assert(sum3([0]) == 0);
Option C is not a valid test because it asserts that the result of sum3([1, '2']) is equal to the string '12', which is not the expected behavior. Option D is also not a valid test because the result of sum3(['hello', 2, 3, 4]) is not NaN, but rather the concatenated string 'hello23'.
Option A and B are correct.
Option C is incorrect because here we are concatenating 1 and '2' and since 12 == '12' the assertion is true but this does not validate the given function because sum3() is used for finding the sum of the array elements only.
This example is full of missspeling but I managed to clean it and test. Run this code below in node.
const sum3 = (arr) => {
if (!arr.length) return 0;
if (arr.length === 1) return arr[0];
if (arr.length === 2) return arr[0] + arr[1];
return arr[0] + arr[1] + arr[2];
};
console.log(sum3([-3, 2 ])); // -1
console.assert(sum3([-3, 2]) == -1);
console.log(sum3([0])); // 0
console.assert(sum3([0]) == 0);
console.log(sum3([1, '2'])); // '12'
console.assert(sum3([1, '2']) == 12); // '12' == 12 is true
console.log(sum3(['hello', 2, 3, 4])); // hello23
console.assert(sum3(['hello', 2, 3, 4]) === NaN); // Assertion failed
In such case Answeras are A,B,C
ans should be A,B