_four X please enter your function description here AssertionError: expected [ 0, 0, NaN ] to deeply equal 2 at Assertion.assertEqual (https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js:774:19) at Assertion.ctx. [as equal] (https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js:4192:25 at context.canonymous> (tests.js:17:38) at callfn (https://cdn.ravgit.com/mochajs/mocha/2.2.5/mocha.js:4562:21) at Test. Runnable.run (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4555:7) at Runner.runTest (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4974:10) at https://cdn.rangit.com/mochajs/mocha/2.2.5/mocha.js:5057:12 at next (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4899:14) at https://cdn.rangit.com/mochajs/mocha/2.2.5/mocha.js:4909:7 at next (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4844:23)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I have been trying to test my javascript program using a test but every time it fails but if l try and run the program it works, not sure what is wrong with my code

9 Mocha Tests
O localhost:63342/comp1231/lab%20practices/practice%20ass/index.html?_ijt=6g3ktof83dgkpk44rolt4k3e5e&_ij reload=RELOAD_ON_S..
A Emmet Shortcuts to...
M Gmail
YouTube
D Watch movies, serie...
O Maps
* HesGoal.Com Sport...
Netflix
09 Mail - Tafadzwa.Ma.
Y Get a G driver's lice...
Communities
A MY GBLearn - Mem..
>
Other favorites
passes: 0 failures: 1 duration: 0.40s
100%
four
X please enter your function description here
AssertionError: expected [ 0, 0, NaN ] to deeply equal 2
at Assertion.assertEqual (https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js:774:19)
at Assertion.ctx.<computed> [as equal] (https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js:4192:25)
at context.<anonymous> (tests.js:17:38)
at callFn (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4562:21)
at Test.Runnable.run (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4555:7)
at Runner.runTest (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4974:10)
at https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:5057:12
at next (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4899:14)
at https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4909:7
at next (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4844:23)
Transcribed Image Text:9 Mocha Tests O localhost:63342/comp1231/lab%20practices/practice%20ass/index.html?_ijt=6g3ktof83dgkpk44rolt4k3e5e&_ij reload=RELOAD_ON_S.. A Emmet Shortcuts to... M Gmail YouTube D Watch movies, serie... O Maps * HesGoal.Com Sport... Netflix 09 Mail - Tafadzwa.Ma. Y Get a G driver's lice... Communities A MY GBLearn - Mem.. > Other favorites passes: 0 failures: 1 duration: 0.40s 100% four X please enter your function description here AssertionError: expected [ 0, 0, NaN ] to deeply equal 2 at Assertion.assertEqual (https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js:774:19) at Assertion.ctx.<computed> [as equal] (https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js:4192:25) at context.<anonymous> (tests.js:17:38) at callFn (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4562:21) at Test.Runnable.run (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4555:7) at Runner.runTest (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4974:10) at https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:5057:12 at next (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4899:14) at https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4909:7 at next (https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js:4844:23)
Online JavaScript Compiler (Edito X
+
A https://www.programiz.com/javascript/online-compiler/
H Apps M Gmail
YouTube
Watch movies, serie...
9 Maps
* HesGoal.Com Sport...
Netflix
0z Mail - Tafadzwa.Ma...
Y Get a G driver's lice...
O MY GBLearn - Mem..
Other bookmarks
E Reading list
Courses
>>
Programiz
תצ Google
Learn Python App
JavaScript Online Compiler
ם מ גו גת? ס
הפ להציג מודעה זו
main.js
Run
Output
Clear
1
"use strict";
node /tmp/ecxNFfwZ3R.js
2
The number of passing grades: 0, failing grades: 4 and class average: 0.0
3
function _four(arr){
The number of passing grades: 0, failing grades: 6 and class average: 25.7
The number of passing grades: 2, failing grades: 0 and class average: 85.0
4
let passed = 0;
let failed = 0;
let average;
7
let sum = 0;
8
for(let i = 0; i < arr.length; i++){
9
if(arr[i] >= 50 )
10
passed++;
11
else
12
failed++;
JS
13
sum += arr[i];
14
}
average = (sum / arr.length).toFixed(1);
console.log("The number of passing grades:
15
16
+ passed + ", failing grades: "+ failed+
and class average: "+ average);
let result;
17
18
result = [passed, failed, average];
19
return result;
20
21
22 }
23 _four([0,0,0,0]);
24 _four([35, 45,25,10,6,33]);
25 _four ([80,90]);
26
... 5
Transcribed Image Text:Online JavaScript Compiler (Edito X + A https://www.programiz.com/javascript/online-compiler/ H Apps M Gmail YouTube Watch movies, serie... 9 Maps * HesGoal.Com Sport... Netflix 0z Mail - Tafadzwa.Ma... Y Get a G driver's lice... O MY GBLearn - Mem.. Other bookmarks E Reading list Courses >> Programiz תצ Google Learn Python App JavaScript Online Compiler ם מ גו גת? ס הפ להציג מודעה זו main.js Run Output Clear 1 "use strict"; node /tmp/ecxNFfwZ3R.js 2 The number of passing grades: 0, failing grades: 4 and class average: 0.0 3 function _four(arr){ The number of passing grades: 0, failing grades: 6 and class average: 25.7 The number of passing grades: 2, failing grades: 0 and class average: 85.0 4 let passed = 0; let failed = 0; let average; 7 let sum = 0; 8 for(let i = 0; i < arr.length; i++){ 9 if(arr[i] >= 50 ) 10 passed++; 11 else 12 failed++; JS 13 sum += arr[i]; 14 } average = (sum / arr.length).toFixed(1); console.log("The number of passing grades: 15 16 + passed + ", failing grades: "+ failed+ and class average: "+ average); let result; 17 18 result = [passed, failed, average]; 19 return result; 20 21 22 } 23 _four([0,0,0,0]); 24 _four([35, 45,25,10,6,33]); 25 _four ([80,90]); 26 ... 5
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY