How to fix the Assertion problem in Nodejs when testing the javascript code? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I test for an empty JavaScript object?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How to decide when to use Node.js?How do I remove a particular element from an array in JavaScript?
When I export an AI 300x60 art board it saves with bigger dimensions
Why did Europeans not widely domesticate foxes?
What *exactly* is electrical current, voltage, and resistance?
Can gravitational waves pass through a black hole?
Why aren't road bicycle wheels tiny?
Has a Nobel Peace laureate ever been accused of war crimes?
France's Public Holidays' Puzzle
Will I be more secure with my own router behind my ISP's router?
Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?
Co-worker works way more than he should
Coin Game with infinite paradox
Will I lose my paid in full property
Are there existing rules/lore for MTG planeswalkers?
Israeli soda type drink
Specify the range of GridLines
Why did Israel vote against lifting the American embargo on Cuba?
Why would the Overseers waste their stock of slaves on the Game?
What were wait-states, and why was it only an issue for PCs?
Is it appropriate to mention a relatable company blog post when you're asked about the company?
Why does Java have support for time zone offsets with seconds precision?
What helicopter has the most rotor blades?
How was Lagrange appointed professor of mathematics so early?
`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY
How to keep bees out of canned beverages?
How to fix the Assertion problem in Nodejs when testing the javascript code?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I test for an empty JavaScript object?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How to decide when to use Node.js?How do I remove a particular element from an array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This is the javascript code of the program to print odd number or even
number between x and y inserted numbers, if x>y, then even numbers are
printed otherwise odd numbers are printed in the array:
const number_game = (x,y) =>
var myArray = [];
if(x>y)
for(i=y+1;i<x;i++)
if(i%2==0)
myArray.push(i);
else
for(i=x+1;i<y;i++)
if(i%2 !=0)
myArray.push(i);
return myArray;
console.log(number_game(2,12));
here is my Test in NodeJS using Assertions
let assert = require("chai").assert;
describe('Challenge', function()
it('should return the right array', function()
assert.deepEqual(number_game(2,12), [3, 5, 7, 9, 11]);
assert.deepEqual(number_game(0,0), []);
// assert.deepEqual(number_game(0,0), []);
);
);
this is the Error Message of the program
expected [ Array(9) ] to deeply equal [ Array(11) ]
javascript node.js
add a comment |
This is the javascript code of the program to print odd number or even
number between x and y inserted numbers, if x>y, then even numbers are
printed otherwise odd numbers are printed in the array:
const number_game = (x,y) =>
var myArray = [];
if(x>y)
for(i=y+1;i<x;i++)
if(i%2==0)
myArray.push(i);
else
for(i=x+1;i<y;i++)
if(i%2 !=0)
myArray.push(i);
return myArray;
console.log(number_game(2,12));
here is my Test in NodeJS using Assertions
let assert = require("chai").assert;
describe('Challenge', function()
it('should return the right array', function()
assert.deepEqual(number_game(2,12), [3, 5, 7, 9, 11]);
assert.deepEqual(number_game(0,0), []);
// assert.deepEqual(number_game(0,0), []);
);
);
this is the Error Message of the program
expected [ Array(9) ] to deeply equal [ Array(11) ]
javascript node.js
Works for me: jsfiddle.net/5xafyope
– Sergiu Paraschiv
Mar 22 at 15:23
thank you for the correction, but it's still crashing for me because i'm using an online compiler , so no need of HTML code for me, i'm using only Javascript and Nodejs. if you have time you can help me out to find a clear solution in javascript and nodejs (for testing )
– Mwafrika Josue
Mar 22 at 19:21
My fiddle proves that the code you are testing is correct. Any errors you are getting are caused by the environment you are testing in. Please help us understand what that environment is.
– Sergiu Paraschiv
Mar 25 at 8:21
add a comment |
This is the javascript code of the program to print odd number or even
number between x and y inserted numbers, if x>y, then even numbers are
printed otherwise odd numbers are printed in the array:
const number_game = (x,y) =>
var myArray = [];
if(x>y)
for(i=y+1;i<x;i++)
if(i%2==0)
myArray.push(i);
else
for(i=x+1;i<y;i++)
if(i%2 !=0)
myArray.push(i);
return myArray;
console.log(number_game(2,12));
here is my Test in NodeJS using Assertions
let assert = require("chai").assert;
describe('Challenge', function()
it('should return the right array', function()
assert.deepEqual(number_game(2,12), [3, 5, 7, 9, 11]);
assert.deepEqual(number_game(0,0), []);
// assert.deepEqual(number_game(0,0), []);
);
);
this is the Error Message of the program
expected [ Array(9) ] to deeply equal [ Array(11) ]
javascript node.js
This is the javascript code of the program to print odd number or even
number between x and y inserted numbers, if x>y, then even numbers are
printed otherwise odd numbers are printed in the array:
const number_game = (x,y) =>
var myArray = [];
if(x>y)
for(i=y+1;i<x;i++)
if(i%2==0)
myArray.push(i);
else
for(i=x+1;i<y;i++)
if(i%2 !=0)
myArray.push(i);
return myArray;
console.log(number_game(2,12));
here is my Test in NodeJS using Assertions
let assert = require("chai").assert;
describe('Challenge', function()
it('should return the right array', function()
assert.deepEqual(number_game(2,12), [3, 5, 7, 9, 11]);
assert.deepEqual(number_game(0,0), []);
// assert.deepEqual(number_game(0,0), []);
);
);
this is the Error Message of the program
expected [ Array(9) ] to deeply equal [ Array(11) ]
javascript node.js
javascript node.js
edited Mar 26 at 13:26
Curr195
1,61331635
1,61331635
asked Mar 22 at 14:57
Mwafrika JosueMwafrika Josue
16
16
Works for me: jsfiddle.net/5xafyope
– Sergiu Paraschiv
Mar 22 at 15:23
thank you for the correction, but it's still crashing for me because i'm using an online compiler , so no need of HTML code for me, i'm using only Javascript and Nodejs. if you have time you can help me out to find a clear solution in javascript and nodejs (for testing )
– Mwafrika Josue
Mar 22 at 19:21
My fiddle proves that the code you are testing is correct. Any errors you are getting are caused by the environment you are testing in. Please help us understand what that environment is.
– Sergiu Paraschiv
Mar 25 at 8:21
add a comment |
Works for me: jsfiddle.net/5xafyope
– Sergiu Paraschiv
Mar 22 at 15:23
thank you for the correction, but it's still crashing for me because i'm using an online compiler , so no need of HTML code for me, i'm using only Javascript and Nodejs. if you have time you can help me out to find a clear solution in javascript and nodejs (for testing )
– Mwafrika Josue
Mar 22 at 19:21
My fiddle proves that the code you are testing is correct. Any errors you are getting are caused by the environment you are testing in. Please help us understand what that environment is.
– Sergiu Paraschiv
Mar 25 at 8:21
Works for me: jsfiddle.net/5xafyope
– Sergiu Paraschiv
Mar 22 at 15:23
Works for me: jsfiddle.net/5xafyope
– Sergiu Paraschiv
Mar 22 at 15:23
thank you for the correction, but it's still crashing for me because i'm using an online compiler , so no need of HTML code for me, i'm using only Javascript and Nodejs. if you have time you can help me out to find a clear solution in javascript and nodejs (for testing )
– Mwafrika Josue
Mar 22 at 19:21
thank you for the correction, but it's still crashing for me because i'm using an online compiler , so no need of HTML code for me, i'm using only Javascript and Nodejs. if you have time you can help me out to find a clear solution in javascript and nodejs (for testing )
– Mwafrika Josue
Mar 22 at 19:21
My fiddle proves that the code you are testing is correct. Any errors you are getting are caused by the environment you are testing in. Please help us understand what that environment is.
– Sergiu Paraschiv
Mar 25 at 8:21
My fiddle proves that the code you are testing is correct. Any errors you are getting are caused by the environment you are testing in. Please help us understand what that environment is.
– Sergiu Paraschiv
Mar 25 at 8:21
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302392%2fhow-to-fix-the-assertion-problem-in-nodejs-when-testing-the-javascript-code%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302392%2fhow-to-fix-the-assertion-problem-in-nodejs-when-testing-the-javascript-code%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Works for me: jsfiddle.net/5xafyope
– Sergiu Paraschiv
Mar 22 at 15:23
thank you for the correction, but it's still crashing for me because i'm using an online compiler , so no need of HTML code for me, i'm using only Javascript and Nodejs. if you have time you can help me out to find a clear solution in javascript and nodejs (for testing )
– Mwafrika Josue
Mar 22 at 19:21
My fiddle proves that the code you are testing is correct. Any errors you are getting are caused by the environment you are testing in. Please help us understand what that environment is.
– Sergiu Paraschiv
Mar 25 at 8:21