Question: my code isnt work Here are the test cases 'use strict'; import * as reducers from ' . / reducers . mjs ' ; test
my code isnt work Here are the test cases 'use strict';
import as reducers from reducersmjs;
testTest sum of an array of numbers using reducer
expectreducereducersreducertoBe;
;
testTest reducer skips all nonnumeric values',
expect true, a truereducereducersreducertoBe;
;
testTest reducer skips a nonnumeric value even if it is the first element',
expectareducereducersreducertoBe;
;
testTest reducer returns if all the elements are nonnumeric',
expectabreducereducersreducertoBe;
;
testTest sum of an array of numbers using reducer
expectreducereducersreducertoBe;
;
testTest reducer throws TypeError exception for a nonnumeric value',
expect true, a truereducereducersreducertoThrowTypeError;
;
testTest reducer throws TypeError exception for a nonnumeric value even when it is the first element',
expectareducereducersreducertoThrowTypeError;
; do you see my attached code? Here it is written out....
Don't change the declaration of this function.
function reducerpreviousValue currentValue
const num parseFloatcurrentValue;
Check if currentValue is not a number
if isNaNnum
If currentValue is not numeric, return previousValue unchanged
return previousValue;
Otherwise, add numeric value to previousValue
return previousValue num;
Don't change the declaration of this function.
function reducerpreviousValue currentValue
const num parseFloatcurrentValue;
Check if currentValue is not a number
if isNaNnum
throw new TypeErrorMy error message';
Otherwise, add numeric value to previousValue
return previousValue num;
Don't add or change anything below this comment.
export reducer reducer;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
